| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853 |
- @extends('layouts.base')
- @section('title', "批量下单")
- @section('content')
- <style>
- .rightlist #app .rightlist-head{line-height:50px;padding:15px 0;}
- .rightlist #app{margin-left:30px;}
- .rightlist #app .el-breadcrumb{padding:30px 0;font-size:16px;}
- /* .el-form-item__label{padding-right:30px;} */
- .tip{font-size:12px;color:#999;font-weight:500}
- .rightlist-head-con{padding-right:20px;font-size:16px;color:#888;}
- /* .rightlist-head-con{float:left;padding-right:20px;font-size:16px;color:#888;} */
- .el-tag{font-weight:700;font-size:15px;margin-bottom:30px;}
- .el-icon-edit{font-size:16px;padding:0 15px;color:#409EFF;cursor: pointer;}
- /* 滑块选择小白点 */
- .el-switch.is-checked .el-switch__core::after {left: 100%;margin-left: -17px;}
- .el-switch__core::after {content: "";position: absolute;top: 1px;left: 1px;border-radius: 100%;transition: all .3s;width: 16px;height: 16px;background-color: #fff;}
- .tip1{font-size:12px;color:red;font-weight:500}
- [v-cloak]{
- display:none;
- }
- /* 计数器样式 */
- .el-input-number__decrease, .el-input-number__increase {width: 25px;}
- .el-input-number .el-input__inner {padding-left: 0px;padding-right: 0px;}
- </style>
- <div class="rightlist">
- <div id="app" v-cloak v-loading="loading">
- <el-breadcrumb separator-class="el-icon-arrow-right">
- <el-breadcrumb-item><a href="{{ yzWebFullUrl('plugin.yz-supply.admin.goods-import.index') }}">返回选品</a></el-breadcrumb-item>
- <el-breadcrumb-item v-html="title"></el-breadcrumb-item>
- </el-breadcrumb>
- <el-form :inline="true" :model="search_form" ref="search_form" @submit.native.prevent>
- <el-form-item>
- <el-input v-model="search_form.title" placeholder="商品名称" style="width: 200px;"></el-input>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_form.cate_v1" placeholder="请选择一级分类" clearable remote filterable @change="searchCateV2">
- <el-option v-for="item in search_cate_v1" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_form.cate_v2" placeholder="请选择二级分类" clearable remote filterable @change="searchCateV3">
- <el-option v-for="item in search_cate_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_form.cate_v3" placeholder="请选择三级分类" clearable remote filterable>
- <el-option v-for="item in search_cate_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
-
- <el-form-item style="float:right;text-align:right;">
- <el-button type="success" icon="el-icon-search" @click="search(1)">搜索</el-button>
- </el-form-item>
- </el-form>
- <el-row :gutter="50">
- <!-- left -->
- <el-col :span="12">
- <!-- 表格start -->
- <el-table :data="list" style="width: 100%" max-height="500" v-loading="all_loading">
- <el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
- <el-table-column label="商品" min-width="180">
- <template slot-scope="scope">
- <div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
- <img :src="scope.row.image_url" style="width:40px;height:40px;">
- [[scope.row.title]]
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="agreement_price" label="价格" max-width="120" align="center"></el-table-column>
- <el-table-column label="库存" prop="stock" max-width="120" align="center"></el-table-column>
- <el-table-column label="选择" width="80" align="center">
- <template slot-scope="scope">
- <el-button size="mini" @click="choose(scope.row)">选择</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
- <el-pagination background layout="prev, pager, next" @current-change="currentChange" :total="total"
- :page-size="per_size" :current-page="current_page"></el-pagination>
- </el-col>
- <!-- 表格end -->
- </el-col>
- <!-- right -->
- <el-col :span="12">
- <div>收货地址:[[address.username]]-[[address.mobile]]-[[address.province_name]]-[[address.city_name]]-[[address.district_name]]
- <el-button type="danger" size="small" style="margin-left:20px" @click="saveAdderss">修改地址</el-button>
- </div>
- <div style="background:#f9f9f9;padding:15px 10px;font-weight:900;border:1px solid #e9e9e9;">
- 订单信息
- <el-button type="danger" size="small" style="margin-left:20px" @click="delAll">清空购物车</el-button>
- </div>
- <!-- 表格start -->
- <el-table :data="cart_list" style="width: 100%;border:1px solid #e9e9e9" v-loading="loading" max-height="500">
- <el-table-column prop="id" label="商品名称" min-width="150" align="center">
- <template slot-scope="scope">
- <div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
- <div>[[scope.row.title]]</div>
- <div v-if="scope.row.option_title" style="color:#999;font-size:12px;">[ [[scope.row.option_title]] ]</div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="price" label="价格" max-width="120" align="center"></el-table-column>
- <el-table-column prop="digitization_name" label="数量" width="120" align="center">
- <template slot-scope="scope">
- <el-input-number v-model="scope.row.num" :step="1" :min="0" style="width:110px;" @change="changeNum(scope.$index)"></el-input-number>
- </template>
- </el-table-column>
- <el-table-column label="金额" prop="total" max-width="120" align="center"></el-table-column>
- <el-table-column label="操作" align="center">
- <template slot-scope="scope">
- <el-button size="mini" type="danger" width="80" @click="del(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 表格end -->
- <div style="background:#f9f9f9;padding:15px 10px;font-weight:900;border:1px solid #e9e9e9;">
- <span>(不包含运费)</span>
- <span>合计:<span style="color:red">[[total_money]]</span>元</span>
- <el-button type="primary" size="small" style="margin-left:20px" @click="windUpAnAccount">结算</el-button>
- </div>
- </el-col>
- </el-row>
- <!-- 选择规格弹出框 -->
- <el-dialog title="选择商品规格" :visible.sync="is_option" width="60%">
- <div>
- <div >
- <h5 style="border-bottom:1px solid #ddd;font-weight:900;">
- 规格
- </h5>
- <div style="display:inline-block;margin:5px;" v-for="(item,index) in option_list" :key="index">
- <el-radio-group v-model="sku_id" style="margin-bottom: 30px;">
- <el-radio-button :label="item.id" style="margin-right: 5px;">[[item.title]]</el-radio-button>
- </el-radio-group>
- </div>
-
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="is_option = false">取 消</el-button>
- <el-button type="primary" @click="confirmOption">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog title="修改收货地址" :visible.sync="is_update_address" width="60%">
- <div>
- <el-form ref="address" :model="address" label-width="15%">
- <el-form-item label="姓名" >
- <el-input v-model="address.username" placeholder="姓名" style="width:70%;"></el-input>
- </el-form-item>
- <el-form-item label="联系方式" >
- <el-input v-model="address.mobile" placeholder="联系方式" style="width:70%;"></el-input>
- </el-form-item>
- <el-form-item label="省市区" prop="" v-loading="areaLoading">
- <el-select v-model="address.province_id" placeholder="请选择省" clearable @change="changeProvince" >
- <el-option v-for="item in province_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
- </el-select>
- <el-select v-model="address.city_id" placeholder="请选择市" clearable @change="changeCity" >
- <el-option v-for="item in city_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
- </el-select>
- <el-select v-model="address.district_id" placeholder="请选择区" clearable @change="changeDistrict" >
- <el-option v-for="item in district_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
- </el-select>
- <el-select v-model="address.street_id" placeholder="请选择街道" clearable >
- <el-option v-for="item in street_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="详细地址" >
- <el-input v-model="address.address" placeholder="详细地址" style="width:70%;"></el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="is_update_address = false">取 消</el-button>
- <el-button type="primary" @click="confirmUpdate">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog :visible.sync="yz_supply_pay_order_show" width="750px" title="汇聚充值">
- <el-row style="margin-left: 15%;margin-bottom:15px; ">
- <el-input v-model="rechargePrice" placeholder="" style="width:70%;"></el-input>
- <el-button type="primary" @click="yzSupplyRecharge()">充值</el-button>
- </el-row>
- <div v-if="rechargePriceCodeUrl != ''" >
- <div style="display: flex;justify-content: center; margin-bottom: 10px;">
- <img :src="this.rechargePriceCodeUrl" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
- </div>
- <p style="color: red;" align="center">*充值之后,自动提交本订单,请检查是否存在未自动提交订单</p>
- </div>
- <div style="height:300px;overflow:auto" id="close-order">
- <div style="background:#eff3f6;border-radius:8px;padding:20px 10px;color:#000;font-weight:500;line-height:36px;">
- <div style="font-size:16px;font-weight:600;color:#000">信息</div>
- <div>
- <div style="display:inline-block;width:150px;text-align:right;margin-right:30px">汇聚余额</div>
- <div style="display:inline-block;">[[balance?balance:0]]</div>
- </div>
- <div>
- <div style="display:inline-block;width:150px;text-align:right;margin-right:30px">订单金额</div>
- <div style="display:inline-block;">[[order_price?order_price:"获取失败"]]</div>
- </div>
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="yz_supply_pay_order_show = false">取 消</el-button>
- </span>
- </el-dialog>
- </div>
- <script>
- window.onload = function (){
- document.body.onkeydown=function(event){
- if(event.keyCode==13){
- event.keyCod=0; return false;
- }
- }
- };
- var app = new Vue({
- el:"#app",
- delimiters: ['[[', ']]'],
- data() {
- let middleground_configuration_id = {!! $middleground_configuration_id !!};
- let title = '{!! $title!!}';
- let address = '{!! $address !!}';
- return{
- is_update_address:false,
- address:address,//收货地址
- sku_id:0,
- detail:[],
- middleground_configuration_id:middleground_configuration_id,
- title:title,
- type:1,
- loading:false,
- table_loading:false,
- all_loading:false,
- total_money:"0",//总金额
- is_exist:0,//商品是否已存在购物车
- is_choose_member:false,//选择会员弹出框
- is_option:false,//选择规格弹出框
- option_list:[],//规格列表
- choose_row:{},//选择商品的信息
- status:[],//选择的商品规格的值
- member_info:"",
- member:{},//选择的会员信息回显
- member_list:[],//会员列表
- search_form:{
- id_v1:"",
- id_v2:"",
- id_v3:"",
- },
- search_cate_v1: [],
- search_cate_v2: [],
- search_cate_v3: [],
- category_list_v2:[],
- category_list_v3:[],
- list:[],
- cart_list:[],
- rules:{},
- //分页
- total:0,
- per_size:0,
- current_page:0,
- rules:{},
- province_list:[],
- city_list:[],
- district_list:[],
- street_list:[],
- create_order_id:0,
- order_price:0,
- balance:0,//中台汇聚余额
- yz_supply_pay_order_show:false,
- rechargePrice:0,//充值金额
- rechargePriceCodeUrl:"",
- pay_sn:"",//充值订单号
- }
-
- },
- created() {
- this.address = JSON.parse(this.address);
- this.getGoodsList();
- this.changeSource();
- this.initProvince();
- },
- methods: {
- confirmUpdate(){
- // province_list:[],
- // city_list:[],
- // district_list:[],
- // street_list:[],
- for (i=0;i<this.province_list.length;i++){
- if (this.province_list[i].id == this.address.province_id){
- this.address.province_name = this.province_list[i].areaname;
- break;
- }
- }
- for (i=0;i<this.city_list.length;i++){
- if (this.city_list[i].id == this.address.city_id){
- this.address.city_name = this.city_list[i].areaname;
- break;
- }
- }
- for (i=0;i<this.district_list.length;i++){
- if (this.district_list[i].id == this.address.district_id){
- this.address.district_name = this.district_list[i].areaname;
- break;
- }
- }
- for (i=0;i<this.street_list.length;i++){
- if (this.street_list[i].id == this.address.street_id){
- this.address.street_name = this.street_list[i].areaname;
- break;
- }
- }
- this.is_update_address = false;
- },
- saveAdderss(){
- let province_id = this.address.province_id;
- let city_id = this.address.city_id;
- let district_id = this.address.district_id;
- let street_id = this.address.street_id;
- this.changeProvince(province_id);
- this.changeCity(city_id);
- this.changeDistrict(district_id);
- this.address.province_id = province_id;
- this.address.city_id = city_id;
- this.address.district_id = district_id;
- this.address.street_id = street_id;
- console.log(this.address);
- this.is_update_address = true;
- },
- getGoodsList(json={}) {
- json['middleground_configuration_id'] = this.middleground_configuration_id;
- let loading = this.$loading({
- lock: true,
- text:"数据加载中",
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- this.all_loading = true;
- this.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.goods-pagination') !!}",json).then(response => {
- if(response.data.result==1){
- this.list = response.data.data.data;
- this.list.forEach((item,index) => {
- item.is_choose = 0;
- // this.list[index].is_choose = 0;
- })
- this.current_page = response.data.data.current_page;
- this.per_size = response.data.data.per_page;
- this.total = response.data.data.total;
- this.total_page = response.data.data.total_page;
- this.total_str = response.data.data.total_str;
- this.sever_ratio = response.data.data.sever_ratio;
- this.all_loading = false;
- } else{
- this.list = [];
- this.current_page = 1;
- this.total = 0;
- this.$message.error(response.data.msg);
- this.all_loading = false;
- }
- loading.close();
- }),(res)=>{
- loading.close();
- this.all_loading = false;
- };
- },
- // 获得商品列表
- getGoodsList1(json) {
- var that = this;
- that.all_loading = true;
- that.$http.post(this.goods_url,json).then(response => {
- if(response.data.result==1){
- this.list = response.data.data.data;
- this.total = response.data.data.total;
- this.current_page = response.data.data.current_page;
- this.per_size = response.data.data.per_page;
- that.all_loading = false;
- }
- else{
- that.$message.error(response.data.msg);
- that.all_loading = false;
- }
- }),function(res){
- that.all_loading = false;
- };
- },
- // 选择商品
- choose(row) {
- let id = row.id;
- let middleground_configuration_id = this.middleground_configuration_id;
- this.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.detail-data') !!}",{id:id,middleground_configuration_id:middleground_configuration_id}).then(res=>{
- if (res.data.result==1) {
- this.detail = res.data.data;
- this.status = [];//初始化规格选择状态
- this.is_option = true;
- this.option_list = this.detail.skus;
- this.sku_id = this.detail.skus[0].id;
- }
- else this.$message.error(res.data.msg);
- })
- },
- // 加入购物车
- pushCart(row) {
- this.cart_list.push(
- {
- id:row.id,
- num:1,
- total:row.price,
- price:row.price,
- thumb:row.thumb,
- title:row.title,
- option_id:0,//规格id
- }
- );
- },
- // 改变数量
- changeNum(index) {
- var that = this;
- if(this.cart_list[index].num < 1) {
- this.del(index);
- return false;
- }
- if(this.cart_list[index].num > this.cart_list[index].stock){
- that.$message.error("超过库存");
- this.cart_list[index].num = this.cart_list[index].stock;
- return false;
- }
- this.cart_list[index].total = this.cart_list[index].num * this.cart_list[index].price;
- this.cart_list[index].total = Number(this.total_money.toString().match(/^\d+(?:\.\d{0,2})?/));
- this.countTotalPrice();
- },
- // 删除
- del(index) {
- this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- // this.delGoods(index);
- this.cart_list.splice(index,1);
- this.countTotalPrice();
- }).catch(() => {
- this.cart_list[index].num++;
- this.$message({type: 'info',message: '已取消删除'});
- });
- },
- // 清空购物车
- delAll() {
- this.$confirm('确定清空购物车吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- // this.delGoods(index);
- this.cart_list = []
- this.countTotalPrice();
- }).catch(() => {
- this.$message({type: 'info',message: '已取消操作'});
- });
- },
- getRechargeStatus(){
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.order-vue-list.get-recharge-status') !!}',{middleground_configuration_id:this.middleground_configuration_id,pay_sn:this.pay_sn}).then(function (response) {
- if (response.data.result) {
- console.log(response.data.data.data);
- //充值状态为0 充值弹窗显示,充值二维码存在 就一直轮询查询到充值成功为止
- if(response.data.data.data.pay_status == 0 ){
- if(this.yz_supply_pay_order_show != true || this.rechargePriceCodeUrl == ""){
- return;
- }
- setTimeout(() => {
- this.getRechargeStatus()
- }, 1000);
- return
- }
- this.yz_supply_pay_order_show = false;
- this.rechargePriceCodeUrl = "";
- this.submitOrder();
- this.$message({type: 'success',message: '充值成功'});
- } else{
- loading.close();
- this.$message({type: 'error',message: response.data.msg});
- }
- },function (response) {
- loading.close();
- this.$message({type: 'error',message: response.data.msg});
- }
- );
- },
- /**
- * 重新提交订单进行支付
- */
- submitOrder(){
- let json = {
- "address": this.address,
- "middleground_configuration_id":this.middleground_configuration_id,
- "cart_list":this.cart_list,
- "id":this.create_order_id
- }
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.bulk-order.yz-order') !!}',json).then(function (response) {
- if(response.data.result==1){
- //代表需要支付
- if(response.data.data.code == 7 && response.data.data.data != undefined && response.data.data.data.code == 1){
- this.create_order_id = response.data.data.yzSupplyBatchOrder.id;
- this.middleground_configuration_id = response.data.data.middleground_configuration_id;
- var order_price = 0
- for (i=0;i<response.data.data.data.order_price.length;i++){
- order_price += parseInt(response.data.data.data.order_price[i])
- }
- this.order_price = (order_price/100).toFixed(2);
- this.rechargePrice = this.order_price;
- this.getBalance()
- this.$message({type: 'error',message: response.data.data.msg});
- return false;
- }
- if (response.data.data.length == 0){
- this.$message({type: 'success',message: '下单成功'});
- this.cart_list = []
- this.countTotalPrice();
- // this.$parent.getData(this.$parent.current_page)
- }else{
- this.$message({type: 'error',message: response.data.data.msg});
- }
- }else{
- this.$message({type: 'error',message: response.data.msg});
- }
- },function (response) {
- this.$message({type: 'error',message: response.data.msg});
- }
- );
- },
- //充值
- yzSupplyRecharge(){
- if (this.rechargePrice <= 0){
- this.$message({type: 'error',message: "请输入充值金额"});
- return
- }
- this.rechargePriceCodeUrl = "";
- let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.order-vue-list.yz-supply-recharge-price') !!}',{middleground_configuration_id:this.middleground_configuration_id,recharge_price:this.rechargePrice}).then(function (response) {
- if (response.data.result) {
- this.rechargePriceCodeUrl = response.data.data.data.rd_Pic;
- this.pay_sn = response.data.data.data.r2_OrderNo;
- this.getRechargeStatus();
- console.log(response.data.data.data);
- loading.close();
- this.$message({type: 'success',message: '操作成功'});
- } else{
- loading.close();
- this.$message({type: 'error',message: response.data.msg});
- }
- },function (response) {
- loading.close();
- this.$message({type: 'error',message: response.data.msg});
- }
- );
- },
- //获取中台汇聚余额
- getBalance(){
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.order-vue-list.get-balance') !!}',{middleground_configuration_id:this.middleground_configuration_id}).then(function (response) {
- if (response.data.result) {
- this.balance = response.data.data.price;
- this.yz_supply_pay_order_show = true;
- this.$message({type: 'success',message: '操作成功'});
- } else{
- this.$message({type: 'error',message: response.data.msg});
- }
- },function (response) {
- this.$message({type: 'error',message: response.data.msg});
- }
- );
- },
- //结算
- windUpAnAccount(){
- let json = {
- "address": this.address,
- "middleground_configuration_id":this.middleground_configuration_id,
- "cart_list":this.cart_list,
- }
- let that = this;
- this.$confirm('确认下单?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.bulk-order.yz-order') !!}",json).then(response => {
- if(response.data.result==1){
- //代表需要支付
- if(response.data.data.code == 7 && response.data.data.data != undefined && response.data.data.data.code == 1){
- this.middleground_configuration_id = response.data.data.middleground_configuration_id;
- this.create_order_id = response.data.data.yzSupplyBatchOrder.id;
- var order_price = 0
- for (i=0;i<response.data.data.data.order_price.length;i++){
- order_price += parseInt(response.data.data.data.order_price[i])
- }
- this.order_price = (order_price/100).toFixed(2);
- this.rechargePrice = this.order_price;
- this.getBalance()
- this.$message({type: 'error',message: response.data.data.msg});
- return false;
- }
- if (response.data.data.length == 0){
- this.$message({type: 'success',message: '下单成功'});
- this.cart_list = []
- this.countTotalPrice();
- // this.$parent.getData(this.$parent.current_page)
- }else{
- this.$message({type: 'error',message: response.data.data.msg});
- }
- }else{
- this.$message({type: 'error',message: response.data.msg});
- }
- that.table_loading = false;
- }),function(res){
- console.log(res);
- that.table_loading = false;
- };
- }).catch(() => {
- that.table_loading = false;
- this.$message({type: 'info',message: '已取消操作'});
- });
- },
- // 确认选择规格
- confirmOption() {
- let is_cunzai = 2;
- // 加入购物车
- for(let i=0;i<this.detail.skus.length;i++){
- if(this.detail.skus[i].id == this.sku_id){
- for(let i1=0;i1<this.cart_list.length;i1++){
- if (this.cart_list[i1].option_id == this.detail.skus[i].id){
- is_cunzai = 1;
- num = this.cart_list[i1].num + 1;
- if (num>this.detail.skus[i].stock){
- that.$message.error("超过库存");
- return
- }
- this.cart_list[i1].num = num;
- }
- }
- if (is_cunzai == 2){
- this.cart_list.push({
- id:this.detail.id,
- specs:this.detail.skus[i].title,
- option_id:this.detail.skus[i].id,//规格id
- title:this.detail.title,
- stock:this.detail.skus[i].stock,
- option_title:this.detail.skus[i].title,
- thumb:this.detail.image_url,
- num:1,
- total:(this.detail.skus[i].price/100).toFixed(2),
- price:(this.detail.skus[i].price/100).toFixed(2),
- })
- }
- this.is_option = false;
- }
- }
- this.countTotalPrice();
- },
- // 分页
- currentChange(page) {
- var that = this;
- // let json = {page:page};
- that.search(page);
- },
- // 一级分类改变
- changeV1(){
- this.search_form.id_v2 = "";
- this.search_form.id_v3 = "";
- this.category_list_v2 = [];
- this.category_list_v3 = [];
- this.category_list.find(item => {
- if(item.id == this.search_form.id_v1) {
- this.category_list_v2 = item.childrens;
- }
- });
- },
- // 二级分类改变
- changeV2(){
- this.search_form.id_v3 = "";
- this.category_list_v3 = [];
- if(this.category_level==3) {
- this.category_list_v2.find(item => {
- if(item.id == this.search_form.id_v2) {
- this.category_list_v3 = item.childrens;
- }
- })
- }
- },
- // 搜索
- search(page) {
- this.getGoodsList({page:page,search:this.search_form});
- },
- changeSource() {
- var that = this;
- that.search_form.cate_v1 = "";
- that.search_form.cate_v2 = "";
- that.search_form.cate_v3 = "";
- that.search_cate_v1 = [];
- that.search_cate_v2 = [];
- that.search_cate_v3 = [];
- // var source = that.search_form.source;
- // 'source':source
- that.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory') !!}', {middleground_configuration_id:this.middleground_configuration_id}).then(response => {
- if (response.data.result == 1) {
- that.search_cate_v1 = response.data.data;
- }
- }), function (res) {
- };
- },
- // 一级分类改变
- searchCateV2() {
- this.search_form.cate_v2 = "";
- this.search_form.cate_v3 = "";
- this.search_cate_v2 = [];
- this.search_cate_v3 = [];
- //搜索二级分类
- var source = this.search_form.source;
- var parent_id = this.search_form.cate_v1;
- // 这里是接口请求数据, 带分页条件
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory') !!}', {
- 'source': source,
- 'parent_id': parent_id,
- 'middleground_configuration_id':this.middleground_configuration_id
- }).then(response => {
- if (response.data.result == 1) {
- this.search_cate_v2 = response.data.data;
- }
- }), function (res) {
- };
- },
- // 二级分类改变
- searchCateV3() {
- this.search_form.cate_v3 = "";
- this.search_cate_v3 = [];
- //搜索三级分类
- var source = this.search_form.source;
- var parent_id = this.search_form.cate_v2;
- // 这里是接口请求数据, 带分页条件
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory') !!}', {
- 'source': source,
- 'parent_id': parent_id,
- 'middleground_configuration_id':this.middleground_configuration_id
- }).then(response => {
- if (response.data.result == 1) {
- this.search_cate_v3 = response.data.data;
- }
- }), function (res) {
- };
- },
- //计算总价格&总数
- countTotalPrice() {
- this.total_money = 0.0; //初始化
- for (var i = 0; i < this.cart_list.length; i++) {
- this.total_money += this.cart_list[i].price * this.cart_list[i].num;
- }
- this.total_money = Number(this.total_money.toString().match(/^\d+(?:\.\d{0,2})?/));
- },
- initProvince(val) {
- this.areaLoading = true;
- this.$http.get("{!! yzWebUrl('area.list.init', ['area_ids'=>'']) !!}"+val).then(response => {
- this.province_list = response.data.data;
- this.areaLoading = false;
- }, response => {
- this.areaLoading = false;
- });
- },
- changeProvince(val) {
- this.city_list = [];
- this.district_list = [];
- this.street_list = [];
- this.address.city_id = "";
- this.address.district_id = "";
- this.address.street_id = "";
- this.areaLoading = true;
- let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
- this.$http.get(url).then(response => {
- if (response.data.data.length) {
- this.city_list = response.data.data;
- } else {
- this.city_list = null;
- }
- this.areaLoading = false;
- }, response => {
- this.areaLoading = false;
- });
- },
- // 市改变
- changeCity(val) {
- this.district_list = [];
- this.street_list = [];
- this.address.district_id = "";
- this.address.street_id = "";
- this.areaLoading = true;
- let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
- this.$http.get(url).then(response => {
- if (response.data.data.length) {
- this.district_list = response.data.data;
- } else {
- this.district_list = null;
- }
- this.areaLoading = false;
- }, response => {
- this.areaLoading = false;
- });
- },
- // 区改变
- changeDistrict(val) {
- console.log(val)
- this.street_list = [];
- this.address.street_id = "";
- this.areaLoading = true;
- let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
- this.$http.get(url).then(response => {
- if (response.data.data.length) {
- this.street_list = response.data.data;
- } else {
- this.street_list = null;
- }
- this.areaLoading = false;
- }, response => {
- this.areaLoading = false;
- });
- },
- // 数组全排序
- permute(arr){
- var rst=[],cur=[]
- function fn(arr){
- var ch
- for(var i=0;i<arr.length;i++){
- ch=arr.splice(i,1)[0]
- cur.push(ch)
- if(arr.length==0){
- rst.push(cur.slice())
- }
- fn(arr)
- arr.splice(i,0,ch)
- cur.pop()
- }
- return rst
- }
- return fn(arr)
- }
- },
- })
- </script>
- @endsection
|