yz-goods.blade.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. @extends('layouts.base')
  2. @section('title', "批量下单")
  3. @section('content')
  4. <style>
  5. .rightlist #app .rightlist-head{line-height:50px;padding:15px 0;}
  6. .rightlist #app{margin-left:30px;}
  7. .rightlist #app .el-breadcrumb{padding:30px 0;font-size:16px;}
  8. /* .el-form-item__label{padding-right:30px;} */
  9. .tip{font-size:12px;color:#999;font-weight:500}
  10. .rightlist-head-con{padding-right:20px;font-size:16px;color:#888;}
  11. /* .rightlist-head-con{float:left;padding-right:20px;font-size:16px;color:#888;} */
  12. .el-tag{font-weight:700;font-size:15px;margin-bottom:30px;}
  13. .el-icon-edit{font-size:16px;padding:0 15px;color:#409EFF;cursor: pointer;}
  14. /* 滑块选择小白点 */
  15. .el-switch.is-checked .el-switch__core::after {left: 100%;margin-left: -17px;}
  16. .el-switch__core::after {content: "";position: absolute;top: 1px;left: 1px;border-radius: 100%;transition: all .3s;width: 16px;height: 16px;background-color: #fff;}
  17. .tip1{font-size:12px;color:red;font-weight:500}
  18. [v-cloak]{
  19. display:none;
  20. }
  21. /* 计数器样式 */
  22. .el-input-number__decrease, .el-input-number__increase {width: 25px;}
  23. .el-input-number .el-input__inner {padding-left: 0px;padding-right: 0px;}
  24. </style>
  25. <div class="rightlist">
  26. <div id="app" v-cloak v-loading="loading">
  27. <el-breadcrumb separator-class="el-icon-arrow-right">
  28. <el-breadcrumb-item><a href="{{ yzWebFullUrl('plugin.yz-supply.admin.goods-import.index') }}">返回选品</a></el-breadcrumb-item>
  29. <el-breadcrumb-item v-html="title"></el-breadcrumb-item>
  30. </el-breadcrumb>
  31. <el-form :inline="true" :model="search_form" ref="search_form" @submit.native.prevent>
  32. <el-form-item>
  33. <el-input v-model="search_form.title" placeholder="商品名称" style="width: 200px;"></el-input>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-select v-model="search_form.cate_v1" placeholder="请选择一级分类" clearable remote filterable @change="searchCateV2">
  37. <el-option v-for="item in search_cate_v1" :key="item.id" :label="item.name" :value="item.id"></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-select v-model="search_form.cate_v2" placeholder="请选择二级分类" clearable remote filterable @change="searchCateV3">
  42. <el-option v-for="item in search_cate_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item>
  46. <el-select v-model="search_form.cate_v3" placeholder="请选择三级分类" clearable remote filterable>
  47. <el-option v-for="item in search_cate_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item style="float:right;text-align:right;">
  51. <el-button type="success" icon="el-icon-search" @click="search(1)">搜索</el-button>
  52. </el-form-item>
  53. </el-form>
  54. <el-row :gutter="50">
  55. <!-- left -->
  56. <el-col :span="12">
  57. <!-- 表格start -->
  58. <el-table :data="list" style="width: 100%" max-height="500" v-loading="all_loading">
  59. <el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
  60. <el-table-column label="商品" min-width="180">
  61. <template slot-scope="scope">
  62. <div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
  63. <img :src="scope.row.image_url" style="width:40px;height:40px;">
  64. [[scope.row.title]]
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="agreement_price" label="价格" max-width="120" align="center"></el-table-column>
  69. <el-table-column label="库存" prop="stock" max-width="120" align="center"></el-table-column>
  70. <el-table-column label="选择" width="80" align="center">
  71. <template slot-scope="scope">
  72. <el-button size="mini" @click="choose(scope.row)">选择</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
  77. <el-pagination background layout="prev, pager, next" @current-change="currentChange" :total="total"
  78. :page-size="per_size" :current-page="current_page"></el-pagination>
  79. </el-col>
  80. <!-- 表格end -->
  81. </el-col>
  82. <!-- right -->
  83. <el-col :span="12">
  84. <div>收货地址:[[address.username]]-[[address.mobile]]-[[address.province_name]]-[[address.city_name]]-[[address.district_name]]
  85. <el-button type="danger" size="small" style="margin-left:20px" @click="saveAdderss">修改地址</el-button>
  86. </div>
  87. <div style="background:#f9f9f9;padding:15px 10px;font-weight:900;border:1px solid #e9e9e9;">
  88. 订单信息
  89. <el-button type="danger" size="small" style="margin-left:20px" @click="delAll">清空购物车</el-button>
  90. </div>
  91. <!-- 表格start -->
  92. <el-table :data="cart_list" style="width: 100%;border:1px solid #e9e9e9" v-loading="loading" max-height="500">
  93. <el-table-column prop="id" label="商品名称" min-width="150" align="center">
  94. <template slot-scope="scope">
  95. <div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
  96. <div>[[scope.row.title]]</div>
  97. <div v-if="scope.row.option_title" style="color:#999;font-size:12px;">[ [[scope.row.option_title]] ]</div>
  98. </div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="price" label="价格" max-width="120" align="center"></el-table-column>
  102. <el-table-column prop="digitization_name" label="数量" width="120" align="center">
  103. <template slot-scope="scope">
  104. <el-input-number v-model="scope.row.num" :step="1" :min="0" style="width:110px;" @change="changeNum(scope.$index)"></el-input-number>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="金额" prop="total" max-width="120" align="center"></el-table-column>
  108. <el-table-column label="操作" align="center">
  109. <template slot-scope="scope">
  110. <el-button size="mini" type="danger" width="80" @click="del(scope.row)">删除</el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. <!-- 表格end -->
  115. <div style="background:#f9f9f9;padding:15px 10px;font-weight:900;border:1px solid #e9e9e9;">
  116. <span>(不包含运费)</span>
  117. <span>合计:<span style="color:red">[[total_money]]</span>元</span>
  118. <el-button type="primary" size="small" style="margin-left:20px" @click="windUpAnAccount">结算</el-button>
  119. </div>
  120. </el-col>
  121. </el-row>
  122. <!-- 选择规格弹出框 -->
  123. <el-dialog title="选择商品规格" :visible.sync="is_option" width="60%">
  124. <div>
  125. <div >
  126. <h5 style="border-bottom:1px solid #ddd;font-weight:900;">
  127. 规格
  128. </h5>
  129. <div style="display:inline-block;margin:5px;" v-for="(item,index) in option_list" :key="index">
  130. <el-radio-group v-model="sku_id" style="margin-bottom: 30px;">
  131. <el-radio-button :label="item.id" style="margin-right: 5px;">[[item.title]]</el-radio-button>
  132. </el-radio-group>
  133. </div>
  134. </div>
  135. </div>
  136. <span slot="footer" class="dialog-footer">
  137. <el-button @click="is_option = false">取 消</el-button>
  138. <el-button type="primary" @click="confirmOption">确 定</el-button>
  139. </span>
  140. </el-dialog>
  141. <el-dialog title="修改收货地址" :visible.sync="is_update_address" width="60%">
  142. <div>
  143. <el-form ref="address" :model="address" label-width="15%">
  144. <el-form-item label="姓名" >
  145. <el-input v-model="address.username" placeholder="姓名" style="width:70%;"></el-input>
  146. </el-form-item>
  147. <el-form-item label="联系方式" >
  148. <el-input v-model="address.mobile" placeholder="联系方式" style="width:70%;"></el-input>
  149. </el-form-item>
  150. <el-form-item label="省市区" prop="" v-loading="areaLoading">
  151. <el-select v-model="address.province_id" placeholder="请选择省" clearable @change="changeProvince" >
  152. <el-option v-for="item in province_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  153. </el-select>
  154. <el-select v-model="address.city_id" placeholder="请选择市" clearable @change="changeCity" >
  155. <el-option v-for="item in city_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  156. </el-select>
  157. <el-select v-model="address.district_id" placeholder="请选择区" clearable @change="changeDistrict" >
  158. <el-option v-for="item in district_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  159. </el-select>
  160. <el-select v-model="address.street_id" placeholder="请选择街道" clearable >
  161. <el-option v-for="item in street_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  162. </el-select>
  163. </el-form-item>
  164. <el-form-item label="详细地址" >
  165. <el-input v-model="address.address" placeholder="详细地址" style="width:70%;"></el-input>
  166. </el-form-item>
  167. </el-form>
  168. </div>
  169. <span slot="footer" class="dialog-footer">
  170. <el-button @click="is_update_address = false">取 消</el-button>
  171. <el-button type="primary" @click="confirmUpdate">确 定</el-button>
  172. </span>
  173. </el-dialog>
  174. <el-dialog :visible.sync="yz_supply_pay_order_show" width="750px" title="汇聚充值">
  175. <el-row style="margin-left: 15%;margin-bottom:15px; ">
  176. <el-input v-model="rechargePrice" placeholder="" style="width:70%;"></el-input>
  177. <el-button type="primary" @click="yzSupplyRecharge()">充值</el-button>
  178. </el-row>
  179. <div v-if="rechargePriceCodeUrl != ''" >
  180. <div style="display: flex;justify-content: center; margin-bottom: 10px;">
  181. <img :src="this.rechargePriceCodeUrl" alt="" style="width:150px;height:150px;border-radius: 5px;cursor: pointer;">
  182. </div>
  183. <p style="color: red;" align="center">*充值之后,自动提交本订单,请检查是否存在未自动提交订单</p>
  184. </div>
  185. <div style="height:300px;overflow:auto" id="close-order">
  186. <div style="background:#eff3f6;border-radius:8px;padding:20px 10px;color:#000;font-weight:500;line-height:36px;">
  187. <div style="font-size:16px;font-weight:600;color:#000">信息</div>
  188. <div>
  189. <div style="display:inline-block;width:150px;text-align:right;margin-right:30px">汇聚余额</div>
  190. <div style="display:inline-block;">[[balance?balance:0]]</div>
  191. </div>
  192. <div>
  193. <div style="display:inline-block;width:150px;text-align:right;margin-right:30px">订单金额</div>
  194. <div style="display:inline-block;">[[order_price?order_price:"获取失败"]]</div>
  195. </div>
  196. </div>
  197. </div>
  198. <span slot="footer" class="dialog-footer">
  199. <el-button @click="yz_supply_pay_order_show = false">取 消</el-button>
  200. </span>
  201. </el-dialog>
  202. </div>
  203. <script>
  204. window.onload = function (){
  205. document.body.onkeydown=function(event){
  206. if(event.keyCode==13){
  207. event.keyCod=0; return false;
  208. }
  209. }
  210. };
  211. var app = new Vue({
  212. el:"#app",
  213. delimiters: ['[[', ']]'],
  214. data() {
  215. let middleground_configuration_id = {!! $middleground_configuration_id !!};
  216. let title = '{!! $title!!}';
  217. let address = '{!! $address !!}';
  218. return{
  219. is_update_address:false,
  220. address:address,//收货地址
  221. sku_id:0,
  222. detail:[],
  223. middleground_configuration_id:middleground_configuration_id,
  224. title:title,
  225. type:1,
  226. loading:false,
  227. table_loading:false,
  228. all_loading:false,
  229. total_money:"0",//总金额
  230. is_exist:0,//商品是否已存在购物车
  231. is_choose_member:false,//选择会员弹出框
  232. is_option:false,//选择规格弹出框
  233. option_list:[],//规格列表
  234. choose_row:{},//选择商品的信息
  235. status:[],//选择的商品规格的值
  236. member_info:"",
  237. member:{},//选择的会员信息回显
  238. member_list:[],//会员列表
  239. search_form:{
  240. id_v1:"",
  241. id_v2:"",
  242. id_v3:"",
  243. },
  244. search_cate_v1: [],
  245. search_cate_v2: [],
  246. search_cate_v3: [],
  247. category_list_v2:[],
  248. category_list_v3:[],
  249. list:[],
  250. cart_list:[],
  251. rules:{},
  252. //分页
  253. total:0,
  254. per_size:0,
  255. current_page:0,
  256. rules:{},
  257. province_list:[],
  258. city_list:[],
  259. district_list:[],
  260. street_list:[],
  261. create_order_id:0,
  262. order_price:0,
  263. balance:0,//中台汇聚余额
  264. yz_supply_pay_order_show:false,
  265. rechargePrice:0,//充值金额
  266. rechargePriceCodeUrl:"",
  267. pay_sn:"",//充值订单号
  268. }
  269. },
  270. created() {
  271. this.address = JSON.parse(this.address);
  272. this.getGoodsList();
  273. this.changeSource();
  274. this.initProvince();
  275. },
  276. methods: {
  277. confirmUpdate(){
  278. // province_list:[],
  279. // city_list:[],
  280. // district_list:[],
  281. // street_list:[],
  282. for (i=0;i<this.province_list.length;i++){
  283. if (this.province_list[i].id == this.address.province_id){
  284. this.address.province_name = this.province_list[i].areaname;
  285. break;
  286. }
  287. }
  288. for (i=0;i<this.city_list.length;i++){
  289. if (this.city_list[i].id == this.address.city_id){
  290. this.address.city_name = this.city_list[i].areaname;
  291. break;
  292. }
  293. }
  294. for (i=0;i<this.district_list.length;i++){
  295. if (this.district_list[i].id == this.address.district_id){
  296. this.address.district_name = this.district_list[i].areaname;
  297. break;
  298. }
  299. }
  300. for (i=0;i<this.street_list.length;i++){
  301. if (this.street_list[i].id == this.address.street_id){
  302. this.address.street_name = this.street_list[i].areaname;
  303. break;
  304. }
  305. }
  306. this.is_update_address = false;
  307. },
  308. saveAdderss(){
  309. let province_id = this.address.province_id;
  310. let city_id = this.address.city_id;
  311. let district_id = this.address.district_id;
  312. let street_id = this.address.street_id;
  313. this.changeProvince(province_id);
  314. this.changeCity(city_id);
  315. this.changeDistrict(district_id);
  316. this.address.province_id = province_id;
  317. this.address.city_id = city_id;
  318. this.address.district_id = district_id;
  319. this.address.street_id = street_id;
  320. console.log(this.address);
  321. this.is_update_address = true;
  322. },
  323. getGoodsList(json={}) {
  324. json['middleground_configuration_id'] = this.middleground_configuration_id;
  325. let loading = this.$loading({
  326. lock: true,
  327. text:"数据加载中",
  328. spinner: 'el-icon-loading',
  329. background: 'rgba(0, 0, 0, 0.7)'
  330. });
  331. this.all_loading = true;
  332. this.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.goods-pagination') !!}",json).then(response => {
  333. if(response.data.result==1){
  334. this.list = response.data.data.data;
  335. this.list.forEach((item,index) => {
  336. item.is_choose = 0;
  337. // this.list[index].is_choose = 0;
  338. })
  339. this.current_page = response.data.data.current_page;
  340. this.per_size = response.data.data.per_page;
  341. this.total = response.data.data.total;
  342. this.total_page = response.data.data.total_page;
  343. this.total_str = response.data.data.total_str;
  344. this.sever_ratio = response.data.data.sever_ratio;
  345. this.all_loading = false;
  346. } else{
  347. this.list = [];
  348. this.current_page = 1;
  349. this.total = 0;
  350. this.$message.error(response.data.msg);
  351. this.all_loading = false;
  352. }
  353. loading.close();
  354. }),(res)=>{
  355. loading.close();
  356. this.all_loading = false;
  357. };
  358. },
  359. // 获得商品列表
  360. getGoodsList1(json) {
  361. var that = this;
  362. that.all_loading = true;
  363. that.$http.post(this.goods_url,json).then(response => {
  364. if(response.data.result==1){
  365. this.list = response.data.data.data;
  366. this.total = response.data.data.total;
  367. this.current_page = response.data.data.current_page;
  368. this.per_size = response.data.data.per_page;
  369. that.all_loading = false;
  370. }
  371. else{
  372. that.$message.error(response.data.msg);
  373. that.all_loading = false;
  374. }
  375. }),function(res){
  376. that.all_loading = false;
  377. };
  378. },
  379. // 选择商品
  380. choose(row) {
  381. let id = row.id;
  382. let middleground_configuration_id = this.middleground_configuration_id;
  383. this.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.detail-data') !!}",{id:id,middleground_configuration_id:middleground_configuration_id}).then(res=>{
  384. if (res.data.result==1) {
  385. this.detail = res.data.data;
  386. this.status = [];//初始化规格选择状态
  387. this.is_option = true;
  388. this.option_list = this.detail.skus;
  389. this.sku_id = this.detail.skus[0].id;
  390. }
  391. else this.$message.error(res.data.msg);
  392. })
  393. },
  394. // 加入购物车
  395. pushCart(row) {
  396. this.cart_list.push(
  397. {
  398. id:row.id,
  399. num:1,
  400. total:row.price,
  401. price:row.price,
  402. thumb:row.thumb,
  403. title:row.title,
  404. option_id:0,//规格id
  405. }
  406. );
  407. },
  408. // 改变数量
  409. changeNum(index) {
  410. var that = this;
  411. if(this.cart_list[index].num < 1) {
  412. this.del(index);
  413. return false;
  414. }
  415. if(this.cart_list[index].num > this.cart_list[index].stock){
  416. that.$message.error("超过库存");
  417. this.cart_list[index].num = this.cart_list[index].stock;
  418. return false;
  419. }
  420. this.cart_list[index].total = this.cart_list[index].num * this.cart_list[index].price;
  421. this.cart_list[index].total = Number(this.total_money.toString().match(/^\d+(?:\.\d{0,2})?/));
  422. this.countTotalPrice();
  423. },
  424. // 删除
  425. del(index) {
  426. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  427. // this.delGoods(index);
  428. this.cart_list.splice(index,1);
  429. this.countTotalPrice();
  430. }).catch(() => {
  431. this.cart_list[index].num++;
  432. this.$message({type: 'info',message: '已取消删除'});
  433. });
  434. },
  435. // 清空购物车
  436. delAll() {
  437. this.$confirm('确定清空购物车吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  438. // this.delGoods(index);
  439. this.cart_list = []
  440. this.countTotalPrice();
  441. }).catch(() => {
  442. this.$message({type: 'info',message: '已取消操作'});
  443. });
  444. },
  445. getRechargeStatus(){
  446. 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) {
  447. if (response.data.result) {
  448. console.log(response.data.data.data);
  449. //充值状态为0 充值弹窗显示,充值二维码存在 就一直轮询查询到充值成功为止
  450. if(response.data.data.data.pay_status == 0 ){
  451. if(this.yz_supply_pay_order_show != true || this.rechargePriceCodeUrl == ""){
  452. return;
  453. }
  454. setTimeout(() => {
  455. this.getRechargeStatus()
  456. }, 1000);
  457. return
  458. }
  459. this.yz_supply_pay_order_show = false;
  460. this.rechargePriceCodeUrl = "";
  461. this.submitOrder();
  462. this.$message({type: 'success',message: '充值成功'});
  463. } else{
  464. loading.close();
  465. this.$message({type: 'error',message: response.data.msg});
  466. }
  467. },function (response) {
  468. loading.close();
  469. this.$message({type: 'error',message: response.data.msg});
  470. }
  471. );
  472. },
  473. /**
  474. * 重新提交订单进行支付
  475. */
  476. submitOrder(){
  477. let json = {
  478. "address": this.address,
  479. "middleground_configuration_id":this.middleground_configuration_id,
  480. "cart_list":this.cart_list,
  481. "id":this.create_order_id
  482. }
  483. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.bulk-order.yz-order') !!}',json).then(function (response) {
  484. if(response.data.result==1){
  485. //代表需要支付
  486. if(response.data.data.code == 7 && response.data.data.data != undefined && response.data.data.data.code == 1){
  487. this.create_order_id = response.data.data.yzSupplyBatchOrder.id;
  488. this.middleground_configuration_id = response.data.data.middleground_configuration_id;
  489. var order_price = 0
  490. for (i=0;i<response.data.data.data.order_price.length;i++){
  491. order_price += parseInt(response.data.data.data.order_price[i])
  492. }
  493. this.order_price = (order_price/100).toFixed(2);
  494. this.rechargePrice = this.order_price;
  495. this.getBalance()
  496. this.$message({type: 'error',message: response.data.data.msg});
  497. return false;
  498. }
  499. if (response.data.data.length == 0){
  500. this.$message({type: 'success',message: '下单成功'});
  501. this.cart_list = []
  502. this.countTotalPrice();
  503. // this.$parent.getData(this.$parent.current_page)
  504. }else{
  505. this.$message({type: 'error',message: response.data.data.msg});
  506. }
  507. }else{
  508. this.$message({type: 'error',message: response.data.msg});
  509. }
  510. },function (response) {
  511. this.$message({type: 'error',message: response.data.msg});
  512. }
  513. );
  514. },
  515. //充值
  516. yzSupplyRecharge(){
  517. if (this.rechargePrice <= 0){
  518. this.$message({type: 'error',message: "请输入充值金额"});
  519. return
  520. }
  521. this.rechargePriceCodeUrl = "";
  522. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  523. 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) {
  524. if (response.data.result) {
  525. this.rechargePriceCodeUrl = response.data.data.data.rd_Pic;
  526. this.pay_sn = response.data.data.data.r2_OrderNo;
  527. this.getRechargeStatus();
  528. console.log(response.data.data.data);
  529. loading.close();
  530. this.$message({type: 'success',message: '操作成功'});
  531. } else{
  532. loading.close();
  533. this.$message({type: 'error',message: response.data.msg});
  534. }
  535. },function (response) {
  536. loading.close();
  537. this.$message({type: 'error',message: response.data.msg});
  538. }
  539. );
  540. },
  541. //获取中台汇聚余额
  542. getBalance(){
  543. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.order-vue-list.get-balance') !!}',{middleground_configuration_id:this.middleground_configuration_id}).then(function (response) {
  544. if (response.data.result) {
  545. this.balance = response.data.data.price;
  546. this.yz_supply_pay_order_show = true;
  547. this.$message({type: 'success',message: '操作成功'});
  548. } else{
  549. this.$message({type: 'error',message: response.data.msg});
  550. }
  551. },function (response) {
  552. this.$message({type: 'error',message: response.data.msg});
  553. }
  554. );
  555. },
  556. //结算
  557. windUpAnAccount(){
  558. let json = {
  559. "address": this.address,
  560. "middleground_configuration_id":this.middleground_configuration_id,
  561. "cart_list":this.cart_list,
  562. }
  563. let that = this;
  564. this.$confirm('确认下单?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  565. that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.bulk-order.yz-order') !!}",json).then(response => {
  566. if(response.data.result==1){
  567. //代表需要支付
  568. if(response.data.data.code == 7 && response.data.data.data != undefined && response.data.data.data.code == 1){
  569. this.middleground_configuration_id = response.data.data.middleground_configuration_id;
  570. this.create_order_id = response.data.data.yzSupplyBatchOrder.id;
  571. var order_price = 0
  572. for (i=0;i<response.data.data.data.order_price.length;i++){
  573. order_price += parseInt(response.data.data.data.order_price[i])
  574. }
  575. this.order_price = (order_price/100).toFixed(2);
  576. this.rechargePrice = this.order_price;
  577. this.getBalance()
  578. this.$message({type: 'error',message: response.data.data.msg});
  579. return false;
  580. }
  581. if (response.data.data.length == 0){
  582. this.$message({type: 'success',message: '下单成功'});
  583. this.cart_list = []
  584. this.countTotalPrice();
  585. // this.$parent.getData(this.$parent.current_page)
  586. }else{
  587. this.$message({type: 'error',message: response.data.data.msg});
  588. }
  589. }else{
  590. this.$message({type: 'error',message: response.data.msg});
  591. }
  592. that.table_loading = false;
  593. }),function(res){
  594. console.log(res);
  595. that.table_loading = false;
  596. };
  597. }).catch(() => {
  598. that.table_loading = false;
  599. this.$message({type: 'info',message: '已取消操作'});
  600. });
  601. },
  602. // 确认选择规格
  603. confirmOption() {
  604. let is_cunzai = 2;
  605. // 加入购物车
  606. for(let i=0;i<this.detail.skus.length;i++){
  607. if(this.detail.skus[i].id == this.sku_id){
  608. for(let i1=0;i1<this.cart_list.length;i1++){
  609. if (this.cart_list[i1].option_id == this.detail.skus[i].id){
  610. is_cunzai = 1;
  611. num = this.cart_list[i1].num + 1;
  612. if (num>this.detail.skus[i].stock){
  613. that.$message.error("超过库存");
  614. return
  615. }
  616. this.cart_list[i1].num = num;
  617. }
  618. }
  619. if (is_cunzai == 2){
  620. this.cart_list.push({
  621. id:this.detail.id,
  622. specs:this.detail.skus[i].title,
  623. option_id:this.detail.skus[i].id,//规格id
  624. title:this.detail.title,
  625. stock:this.detail.skus[i].stock,
  626. option_title:this.detail.skus[i].title,
  627. thumb:this.detail.image_url,
  628. num:1,
  629. total:(this.detail.skus[i].price/100).toFixed(2),
  630. price:(this.detail.skus[i].price/100).toFixed(2),
  631. })
  632. }
  633. this.is_option = false;
  634. }
  635. }
  636. this.countTotalPrice();
  637. },
  638. // 分页
  639. currentChange(page) {
  640. var that = this;
  641. // let json = {page:page};
  642. that.search(page);
  643. },
  644. // 一级分类改变
  645. changeV1(){
  646. this.search_form.id_v2 = "";
  647. this.search_form.id_v3 = "";
  648. this.category_list_v2 = [];
  649. this.category_list_v3 = [];
  650. this.category_list.find(item => {
  651. if(item.id == this.search_form.id_v1) {
  652. this.category_list_v2 = item.childrens;
  653. }
  654. });
  655. },
  656. // 二级分类改变
  657. changeV2(){
  658. this.search_form.id_v3 = "";
  659. this.category_list_v3 = [];
  660. if(this.category_level==3) {
  661. this.category_list_v2.find(item => {
  662. if(item.id == this.search_form.id_v2) {
  663. this.category_list_v3 = item.childrens;
  664. }
  665. })
  666. }
  667. },
  668. // 搜索
  669. search(page) {
  670. this.getGoodsList({page:page,search:this.search_form});
  671. },
  672. changeSource() {
  673. var that = this;
  674. that.search_form.cate_v1 = "";
  675. that.search_form.cate_v2 = "";
  676. that.search_form.cate_v3 = "";
  677. that.search_cate_v1 = [];
  678. that.search_cate_v2 = [];
  679. that.search_cate_v3 = [];
  680. // var source = that.search_form.source;
  681. // 'source':source
  682. that.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory') !!}', {middleground_configuration_id:this.middleground_configuration_id}).then(response => {
  683. if (response.data.result == 1) {
  684. that.search_cate_v1 = response.data.data;
  685. }
  686. }), function (res) {
  687. };
  688. },
  689. // 一级分类改变
  690. searchCateV2() {
  691. this.search_form.cate_v2 = "";
  692. this.search_form.cate_v3 = "";
  693. this.search_cate_v2 = [];
  694. this.search_cate_v3 = [];
  695. //搜索二级分类
  696. var source = this.search_form.source;
  697. var parent_id = this.search_form.cate_v1;
  698. // 这里是接口请求数据, 带分页条件
  699. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory') !!}', {
  700. 'source': source,
  701. 'parent_id': parent_id,
  702. 'middleground_configuration_id':this.middleground_configuration_id
  703. }).then(response => {
  704. if (response.data.result == 1) {
  705. this.search_cate_v2 = response.data.data;
  706. }
  707. }), function (res) {
  708. };
  709. },
  710. // 二级分类改变
  711. searchCateV3() {
  712. this.search_form.cate_v3 = "";
  713. this.search_cate_v3 = [];
  714. //搜索三级分类
  715. var source = this.search_form.source;
  716. var parent_id = this.search_form.cate_v2;
  717. // 这里是接口请求数据, 带分页条件
  718. this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.goods-import.getChildrenCategory') !!}', {
  719. 'source': source,
  720. 'parent_id': parent_id,
  721. 'middleground_configuration_id':this.middleground_configuration_id
  722. }).then(response => {
  723. if (response.data.result == 1) {
  724. this.search_cate_v3 = response.data.data;
  725. }
  726. }), function (res) {
  727. };
  728. },
  729. //计算总价格&总数
  730. countTotalPrice() {
  731. this.total_money = 0.0; //初始化
  732. for (var i = 0; i < this.cart_list.length; i++) {
  733. this.total_money += this.cart_list[i].price * this.cart_list[i].num;
  734. }
  735. this.total_money = Number(this.total_money.toString().match(/^\d+(?:\.\d{0,2})?/));
  736. },
  737. initProvince(val) {
  738. this.areaLoading = true;
  739. this.$http.get("{!! yzWebUrl('area.list.init', ['area_ids'=>'']) !!}"+val).then(response => {
  740. this.province_list = response.data.data;
  741. this.areaLoading = false;
  742. }, response => {
  743. this.areaLoading = false;
  744. });
  745. },
  746. changeProvince(val) {
  747. this.city_list = [];
  748. this.district_list = [];
  749. this.street_list = [];
  750. this.address.city_id = "";
  751. this.address.district_id = "";
  752. this.address.street_id = "";
  753. this.areaLoading = true;
  754. let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
  755. this.$http.get(url).then(response => {
  756. if (response.data.data.length) {
  757. this.city_list = response.data.data;
  758. } else {
  759. this.city_list = null;
  760. }
  761. this.areaLoading = false;
  762. }, response => {
  763. this.areaLoading = false;
  764. });
  765. },
  766. // 市改变
  767. changeCity(val) {
  768. this.district_list = [];
  769. this.street_list = [];
  770. this.address.district_id = "";
  771. this.address.street_id = "";
  772. this.areaLoading = true;
  773. let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
  774. this.$http.get(url).then(response => {
  775. if (response.data.data.length) {
  776. this.district_list = response.data.data;
  777. } else {
  778. this.district_list = null;
  779. }
  780. this.areaLoading = false;
  781. }, response => {
  782. this.areaLoading = false;
  783. });
  784. },
  785. // 区改变
  786. changeDistrict(val) {
  787. console.log(val)
  788. this.street_list = [];
  789. this.address.street_id = "";
  790. this.areaLoading = true;
  791. let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
  792. this.$http.get(url).then(response => {
  793. if (response.data.data.length) {
  794. this.street_list = response.data.data;
  795. } else {
  796. this.street_list = null;
  797. }
  798. this.areaLoading = false;
  799. }, response => {
  800. this.areaLoading = false;
  801. });
  802. },
  803. // 数组全排序
  804. permute(arr){
  805. var rst=[],cur=[]
  806. function fn(arr){
  807. var ch
  808. for(var i=0;i<arr.length;i++){
  809. ch=arr.splice(i,1)[0]
  810. cur.push(ch)
  811. if(arr.length==0){
  812. rst.push(cur.slice())
  813. }
  814. fn(arr)
  815. arr.splice(i,0,ch)
  816. cur.pop()
  817. }
  818. return rst
  819. }
  820. return fn(arr)
  821. }
  822. },
  823. })
  824. </script>
  825. @endsection