shoppingCart.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. <template>
  2. <view v-if="checkStatus == '通过'">
  3. <view style="background-color: #fff;padding: 20rpx;border-radius: 20rpx;">
  4. <view style="display: flex;justify-content: space-between;">
  5. <view>
  6. <view style="display: flex;width: 580rpx;" v-if="!editDel" @click="clickAddress">
  7. <u-icon name="map"></u-icon>
  8. <u--text :text="addres.belongtoarea + addres.detailedAddress" size="28rpx" lines="1"></u--text>
  9. </view>
  10. </view>
  11. <!-- <view style="display: flex;">
  12. <view style="margin-right: 40rpx;">|</view>
  13. <view @click="editDel = !editDel">{{editDel?'取消':'编辑'}}</view>
  14. </view> -->
  15. </view>
  16. </view>
  17. <u-checkbox-group v-model="companyValue" placement="column" @change="companyChange" :size='28'>
  18. <view class="collection" v-for="(item,index) in dataList" :key="index">
  19. <view style="margin-left: 40rpx;">
  20. <u-checkbox activeColor="#FD4B09" shape="circle" :customStyle="{marginBottom: '8px'}"
  21. :label="item.name" :name="item.name" labelSize="36rpx"></u-checkbox>
  22. </view>
  23. <view style="margin-left: 20rpx;display: flex;align-items: center;" v-for="(ite,ind) in item.list"
  24. :key="ind">
  25. <view>
  26. <image v-for="(li,inde) in ite.filesList" :key="inde" v-if="li.version === '0'" :src="li.url"
  27. style="width: 200rpx;height: 200rpx;border-radius: 20rpx;">
  28. </image>
  29. </view>
  30. <view class="goods">
  31. <view style="display: flex;">
  32. <u--text :text="ite.goodsName" size="24rpx" lines="2"></u--text>
  33. <u-icon name="trash" size="52rpx" @click="deleteGoods(ite.id)"></u-icon>
  34. </view>
  35. <view class="price">
  36. <view>{{Number(ite.price)}}<text
  37. style="font-size: 24rpx;margin-bottom: 8rpx;margin-left: 4rpx;">积分</text>
  38. </view>
  39. <view v-if="!editDel">
  40. <u-number-box v-model="ite.goodsNum" :min="1" buttonSize="40rpx"
  41. @change="(val)=>{statistics(val,index,ind)}"></u-number-box>
  42. </view>
  43. </view>
  44. </view>
  45. <!--<view v-if="editDel">
  46. </view> -->
  47. </view>
  48. </view>
  49. </u-checkbox-group>
  50. <view style="height: 120rpx;"></view>
  51. <view class="submitBar">
  52. <view class="bar_view">
  53. <view style="display: flex;align-items: center;">
  54. <view style="margin-left: 40rpx;">
  55. <u-checkbox-group v-model="radiovalue" placement="column" @change="radioGroupChange" :size='28'>
  56. <u-checkbox label="全选" name="全选" activeColor="#FD4B09" shape="circle"
  57. :labelSize='18'></u-checkbox>
  58. </u-checkbox-group>
  59. </view>
  60. <view v-if="!editDel" style="margin-left: 20rpx;">
  61. <view>总计:<text style="font-size: 36rpx;">{{totalPrice}}</text><text
  62. style="font-size: 20rpx;margin-bottom: 8rpx;margin-left: 4rpx;">积分</text></view>
  63. <!-- <view style="font-size: 22rpx;color: #FD4B09;">运费:¥{{totalFreight}}</view> -->
  64. </view>
  65. </view>
  66. <view style="height: 120rpx;display: flex;color: #fff;">
  67. <view v-if="!editDel" class="redbutton" @click="submit()">立即支付</view>
  68. <view v-else class="redbutton" @click="deleteShopping">删除</view>
  69. <!-- <u-button shape="circle" size="small" text="立即支付" v-if="!editDel"
  70. :disabled="this.selectedProduct.length == 0"
  71. color="linear-gradient(0deg, #FD5003 0%, #FBA680 100%)" @click="submit"></u-button>
  72. <u-button shape="circle" size="small" text="删除" v-else :disabled="this.selectedProduct.length == 0"
  73. color="linear-gradient(0deg, #FD5003 0%, #FBA680 100%)" @click="deleteShopping"></u-button> -->
  74. </view>
  75. </view>
  76. </view>
  77. <u-empty style="position: absolute;top: 45%;left: 50%;transform:translate(-50%,-50%)"
  78. v-if="dataList.length == 0" mode="car" icon="http://cdn.uviewui.com/uview/empty/car.png" />
  79. <u-popup :show="qrcodeshow" mode="center" :closeable="true" @close="qrcodeclose">
  80. <view style="padding: 20rpx;">
  81. <view style="font-size: 26rpx;">截屏二维码支付</view>
  82. <view>
  83. <uqrcode ref="uqrcode" canvas-id="qrcode" size="600" sizeUnit="rpx" :value="qrcodeurl"
  84. :options="{ margin: 5 }"></uqrcode>
  85. <!-- options 配置项 https://uqrcode.cn/doc/document/native.html#%E5%AE%9E%E4%BE%8B%E6%96%B9%E6%B3%95 -->
  86. </view>
  87. <view>
  88. <!-- {{qrcodeData.contacts}} -->
  89. <view style="font-size: 34rpx;font-weight: 500;">{{qrcodeData.salesCompanyName}}</view>
  90. <view style="color: #9a9a9a;font-size: 26rpx;">
  91. <text>金额:</text>
  92. <text style="color: #FD4B09;font-size: 30rpx;">{{qrcodeData.salesAmount}}积分</text>
  93. </view>
  94. <view style="color: #9a9a9a;font-size: 26rpx;">二维码有效期: {{qrcodeData.businesDate}}</view>
  95. </view>
  96. </view>
  97. </u-popup>
  98. <!-- 提取去登录 -->
  99. <u-modal :show="adminShow" :showCancelButton="true" content='当前还未登录请先登录!!' @confirm="adminConfirm"
  100. @cancel="adminCancel"></u-modal>
  101. <u-modal :show="inventoryShow" title="库存不足" @confirm="inventoryShow=false;inventoryContent='';companyValue=[]">
  102. <view class="slot-content">
  103. <rich-text :nodes="inventoryContent"></rich-text>
  104. </view>
  105. </u-modal>
  106. </view>
  107. </template>
  108. <script>
  109. import {
  110. shoppingCartList,
  111. generateOrder,
  112. generateOrderLimit,
  113. shoppingCartUpdate,
  114. getCorpsAddr,
  115. paramserviceDetail,
  116. getParamservice,
  117. isProcurement,
  118. generateOrderPoints
  119. } from '@/api/tabBar/shoppingCart.js'
  120. import {
  121. registerRuntimeCompiler
  122. } from "vue"
  123. import {
  124. details
  125. } from '@/api/views/personalInformation/index.js'
  126. import {
  127. appDetail
  128. } from '@/api/views/salesSlip/index.js'
  129. import {
  130. activityList
  131. } from '@/api/tabBar/activity.js'
  132. export default {
  133. data() {
  134. return {
  135. qrcodeshow: false, // 二维码弹窗
  136. qrcodeData: [], // 二维码数据
  137. qrcodeurl: '', // 二维码参数
  138. editDel: false,
  139. radiovalue: [],
  140. companyValue: [],
  141. dataList: [],
  142. companyValueLength: 0,
  143. selectedProduct: [],
  144. totalPrice: 0,
  145. totalFreight: 0,
  146. addres: {},
  147. checkStatus: null,
  148. adminShow: false,
  149. inventoryShow: false,
  150. inventoryContent: '',
  151. freight: 5,
  152. }
  153. },
  154. watch: {
  155. companyValue() {
  156. if (this.companyValue.length != 0 || this.companyValueLength != 0) {
  157. if (this.companyValue.length == this.companyValueLength) {
  158. this.radiovalue = ["全选"]
  159. } else {
  160. this.radiovalue = []
  161. }
  162. }
  163. this.statistics()
  164. }
  165. },
  166. created() {
  167. activityList({
  168. current: 1,
  169. size: 10,
  170. status: 1
  171. }).then(res => {
  172. uni.setTabBarBadge({
  173. index: 2, // tabIndex,tabBar的哪一项,从0开始
  174. text: res.data.total.toString() // 显示的文本,超过 99 显示成 “…”
  175. })
  176. })
  177. if (uni.getStorageSync('userInfo').tenant_id == '000000') {
  178. this.adminShow = true
  179. return
  180. }
  181. // 获取审核状态
  182. details().then(res => {
  183. this.checkStatus = res.data.checkStatus
  184. uni.setStorageSync('checkStatus', res.data.checkStatus);
  185. console.log(1111111)
  186. if (this.checkStatus != '通过') {
  187. uni.showToast({
  188. title: "当前用户未授权,请联系客服",
  189. icon: "none",
  190. mask: true
  191. });
  192. // uni.switchTab({
  193. // url:'/pages/tabBar/home'
  194. // })
  195. // return
  196. }
  197. })
  198. this.editDel = false
  199. this.companyValue = []
  200. shoppingCartList({
  201. whetherIntegral: '1'
  202. }).then(res => {
  203. this.dataList = res.data
  204. this.companyValueLength = this.dataList.length
  205. this.inventoryfun(res.data)
  206. let num = 0
  207. res.data.forEach(e => {
  208. console.log(e.list)
  209. num = num + e.list.length
  210. })
  211. uni.setTabBarBadge({
  212. index: 3, // tabIndex,tabBar的哪一项,从0开始
  213. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  214. })
  215. })
  216. getCorpsAddr().then(res => {
  217. this.addres = res.data
  218. })
  219. // 支付成功之后的回调
  220. let options = wx.getEnterOptionsSync();
  221. if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3') {
  222. // 代表从收银台小程序返回
  223. let extraData = options.referrerInfo.extraData;
  224. if (!extraData) {
  225. // "当前通过物理按键返回,未接收到返参,建议自行查询交易结果";
  226. console.log('当前通过物理按键返回,未接收到返参,建议自行查询交易结果');
  227. } else {
  228. if (extraData.code == 'success') {
  229. // "支付成功";
  230. } else if (extraData.code == 'cancel') {
  231. // "支付已取消";
  232. console.log(extraData, '支付已取消');
  233. } else {
  234. console.log(extraData, '失败');
  235. // "支付失败:" + extraData.errmsg;
  236. }
  237. }
  238. }
  239. isProcurement({
  240. "param": "freight"
  241. }).then(res => {
  242. // res.data.data === '1'
  243. this.freight = res.data
  244. })
  245. },
  246. methods: {
  247. tabbarClick(tab) {
  248. // uni.$u.route('/pages/integralMall/'+tab);
  249. uni.navigateTo({
  250. url: '/pages/integralMall/' + tab
  251. })
  252. },
  253. // 库存弹窗
  254. inventoryfun(arr) {
  255. let sum = ''
  256. arr.map((item, index) => {
  257. item.list.map(ite => {
  258. if (Number(ite.goodsNum) > Number(ite.inventory)) {
  259. sum += `${ite.goodsName} 的库存数量为${ite.inventory}<br>`
  260. }
  261. return ite
  262. })
  263. return item
  264. })
  265. if (sum != '') {
  266. this.inventoryContent = sum + '请修正数量后重新结算'
  267. this.inventoryShow = true
  268. return true
  269. }
  270. return false
  271. },
  272. // admin确认
  273. adminConfirm() {
  274. uni.clearStorageSync();
  275. uni.redirectTo({
  276. url: '/pages/login/login'
  277. })
  278. },
  279. // admin取消
  280. adminCancel() {
  281. uni.switchTab({
  282. url: '/pages/tabBar/home'
  283. })
  284. },
  285. // 弹窗关闭
  286. qrcodeclose() {
  287. this.qrcodeshow = false
  288. uni.showLoading({
  289. title: '加载中',
  290. mask: true
  291. });
  292. // 详情调用
  293. shoppingCartList({
  294. whetherIntegral: '1'
  295. }).then(res => {
  296. this.dataList = res.data
  297. this.companyValueLength = this.dataList.length
  298. uni.hideLoading();
  299. }).catch(err => {
  300. uni.hideLoading();
  301. })
  302. },
  303. clickAddress() {
  304. this.$u.route('/pages/views/personalInformation/addressManagement');
  305. },
  306. getList() {
  307. shoppingCartList({
  308. whetherIntegral: '1'
  309. }).then(res => {
  310. this.dataList = res.data
  311. this.companyValueLength = this.dataList.length
  312. let num = 0
  313. res.data.forEach(e => {
  314. num = num + e.list.length
  315. })
  316. uni.setTabBarBadge({
  317. index: 3, // tabIndex,tabBar的哪一项,从0开始
  318. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  319. })
  320. uni.hideLoading();
  321. }).catch(err => {
  322. uni.hideLoading();
  323. })
  324. },
  325. deleteGoods(val) {
  326. let _this = this
  327. uni.showModal({
  328. title: '提示',
  329. content: '是否删除?',
  330. success: function(res) {
  331. if (res.confirm) {
  332. uni.showLoading({
  333. title: '加载中',
  334. mask: true
  335. });
  336. shoppingCartUpdate({
  337. ids: val
  338. }).then(res => {
  339. uni.showToast({
  340. title: "删除成功",
  341. icon: 'none'
  342. });
  343. uni.showLoading({
  344. title: '加载中',
  345. mask: true
  346. });
  347. _this.getList()
  348. // this.editDel = false
  349. _this.companyValue = []
  350. uni.hideLoading();
  351. }).catch(err => {
  352. uni.hideLoading();
  353. })
  354. } else if (res.cancel) {
  355. console.log('用户点击取消');
  356. }
  357. }
  358. });
  359. },
  360. deleteShopping() {
  361. if (this.selectedProduct.length == 0) {
  362. uni.showToast({
  363. title: "请先选择要支付的商品",
  364. icon: 'none'
  365. });
  366. return
  367. }
  368. let data = []
  369. for (let item of this.companyValue) {
  370. for (let ite of this.dataList) {
  371. if (item == ite.name) {
  372. for (let it of ite.list) {
  373. data.push(it.id)
  374. }
  375. }
  376. }
  377. }
  378. uni.showLoading({
  379. title: '加载中',
  380. mask: true
  381. });
  382. shoppingCartUpdate({
  383. ids: data.join(',')
  384. }).then(res => {
  385. uni.showToast({
  386. title: "删除成功",
  387. icon: 'none'
  388. });
  389. uni.hideLoading();
  390. uni.showLoading({
  391. title: '加载中',
  392. mask: true
  393. });
  394. this.editDel = false
  395. this.companyValue = []
  396. shoppingCartList({
  397. whetherIntegral: '1'
  398. }).then(res => {
  399. this.dataList = res.data
  400. this.companyValueLength = this.dataList.length
  401. uni.hideLoading();
  402. }).catch(err => {
  403. uni.hideLoading();
  404. })
  405. }).catch(err => {
  406. uni.hideLoading();
  407. })
  408. },
  409. // 立即支付
  410. async submit() {
  411. if (this.selectedProduct.length == 0) {
  412. uni.showToast({
  413. title: "请先选择要支付的商品",
  414. icon: 'none'
  415. });
  416. return
  417. }
  418. if (this.inventoryfun(this.dataList)) {
  419. return
  420. }
  421. if (this.companyValue.length > 0) {
  422. let data = []
  423. for (let item of this.companyValue) {
  424. for (let ite of this.dataList) {
  425. if (item == ite.name) {
  426. data.push({
  427. name: item,
  428. list: ite.list
  429. })
  430. }
  431. }
  432. }
  433. let _this = this
  434. uni.showModal({
  435. title: '提示',
  436. content: '是否确认兑换?',
  437. success: function(res) {
  438. if (res.confirm) {
  439. uni.showLoading({
  440. title: '加载中',
  441. mask: true
  442. });
  443. generateOrderPoints({
  444. address: _this.addres.belongtoarea + _this.addres
  445. .detailedAddress,
  446. list: data,
  447. }).then(res => {
  448. uni.hideLoading({
  449. noConflict: true
  450. });
  451. uni.showToast({
  452. title: res.data,
  453. icon: "none",
  454. });
  455. shoppingCartList({
  456. whetherIntegral: '1'
  457. }).then(res => {
  458. _this.dataList = res.data
  459. _this.companyValueLength = _this.dataList.length
  460. })
  461. })
  462. }
  463. }
  464. });
  465. // 判断是否用额度支付
  466. // const personRef = await details()
  467. // console.log(personRef.data, 349);
  468. // const totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
  469. // 是否开通额度
  470. // getParamservice(1, 10, {
  471. // paramKey: 'WeChat.shipping.notification'
  472. // }).then(res => {
  473. // console.log(res)
  474. // if (res.data.records.length > 0) {
  475. // let payType = res.data.records[0].paramValue == 1 ? 'W11' : 'W06'
  476. // if (personRef.data.ifLimitAmount == 1) {
  477. // // 额度是否够用
  478. // if (Number(personRef.data.limitAmount >= totalPrice)) {
  479. // // 额度
  480. // // this.payType='W06'
  481. // generateOrderLimit({
  482. // payType: res.data.records[0].paramValue == 1 ? 'W11' : 'W06',
  483. // address: this.addres.belongtoarea + this.addres.detailedAddress,
  484. // list: data,
  485. // }).then(res => {
  486. // uni.hideLoading();
  487. // uni.showToast({
  488. // title: '支付成功',
  489. // mask: true,
  490. // duration: 2000
  491. // });
  492. // setTimeout(function() {
  493. // uni.hideLoading();
  494. // }, 1000);
  495. // // 详情调用
  496. // shoppingCartList().then(res => {
  497. // this.dataList = res.data
  498. // this.companyValueLength = this.dataList.length
  499. // }).catch(err => {})
  500. // })
  501. // return
  502. // }
  503. // }
  504. // // 正常支付
  505. // generateOrder({
  506. // payType: res.data.records[0].paramValue == 1 ? 'W11' : 'W06',
  507. // address: this.addres.belongtoarea + this.addres.detailedAddress,
  508. // list: data,
  509. // }).then(res => {
  510. // let generateOrderData = res.data
  511. // paramserviceDetail({
  512. // paramKey: 'cashier.payment'
  513. // }).then(res => {
  514. // let paramservice = res.data
  515. // // paramservice.paramValue=0
  516. // // 判断是调支付台的接口还是微信支付的接口
  517. // if (paramservice && paramservice.paramValue == '1') {
  518. // console.log(222211111111);
  519. // // uni.hideLoading();
  520. // // uni.requestPayment({
  521. // // provider: "wxpay",
  522. // // appId: generateOrderData.appId,
  523. // // timeStamp: generateOrderData.timeStamp,
  524. // // nonceStr: generateOrderData.nonceStr,
  525. // // package: generateOrderData.package,
  526. // // signType: generateOrderData.signType,
  527. // // paySign: generateOrderData.paySign,
  528. // // success(res) {
  529. // // uni.showToast({
  530. // // title: '支付成功',
  531. // // mask: true,
  532. // // duration: 2000
  533. // // });
  534. // // setTimeout(function() {
  535. // // uni.hideLoading();
  536. // // // this_.refresh(res.data.data.id)
  537. // // }, 1000);
  538. // // },
  539. // // fail(e) {
  540. // // console.log(e,11111111);
  541. // // uni.showToast({
  542. // // title: "支付失败",
  543. // // icon: 'none',
  544. // // mask: true
  545. // // });
  546. // // setTimeout(function() {
  547. // // uni.hideLoading();
  548. // // // this_.refresh(res.data.id)
  549. // // }, 1000);
  550. // // }
  551. // // })
  552. // let obj = {
  553. // appId: 'wxef277996acc166c3',
  554. // extraData: {
  555. // cusid: generateOrderData.cusid,
  556. // appid: generateOrderData.appid,
  557. // orgid: generateOrderData.orgid,
  558. // version: generateOrderData.version,
  559. // trxamt: generateOrderData.trxamt,
  560. // reqsn: generateOrderData.reqsn,
  561. // notify_url: generateOrderData.notify_url,
  562. // body: generateOrderData.body,
  563. // remark: generateOrderData.remark,
  564. // validtime: generateOrderData.validtime,
  565. // limit_pay: generateOrderData.limit_pay,
  566. // randomstr: generateOrderData.randomstr,
  567. // paytype: generateOrderData.paytype,
  568. // signtype: generateOrderData.signtype,
  569. // sign: generateOrderData.sign,
  570. // },
  571. // }
  572. // console.log(obj);
  573. // if (!generateOrderData.reqsn) {
  574. // uni.showToast({
  575. // title: '当前订单号为空,请联系供应商!!!',
  576. // icon: 'none',
  577. // mask: true,
  578. // duration: 2000
  579. // });
  580. // // 详情调用
  581. // shoppingCartList().then(res => {
  582. // this.dataList = res.data
  583. // this.companyValueLength = this.dataList
  584. // .length
  585. // }).catch(err => {})
  586. // return
  587. // }
  588. // wx.openEmbeddedMiniProgram({
  589. // appId: 'wxef277996acc166c3',
  590. // extraData: {
  591. // cusid: generateOrderData.cusid,
  592. // appid: generateOrderData.appid,
  593. // orgid: generateOrderData.orgid,
  594. // version: generateOrderData.version,
  595. // trxamt: generateOrderData.trxamt,
  596. // reqsn: generateOrderData.reqsn,
  597. // notify_url: generateOrderData
  598. // .notify_url,
  599. // body: generateOrderData.body,
  600. // remark: generateOrderData.remark,
  601. // validtime: generateOrderData.validtime,
  602. // // limit_pay: generateOrderData.limit_pay,
  603. // limit_pay: "",
  604. // randomstr: generateOrderData.randomstr,
  605. // paytype: generateOrderData.paytype,
  606. // signtype: generateOrderData.signtype,
  607. // sign: generateOrderData.sign,
  608. // },
  609. // success: (a) => {
  610. // uni.hideLoading();
  611. // },
  612. // fail: (err) => {
  613. // uni.hideLoading();
  614. // }
  615. // })
  616. // } else {
  617. // console.log(2222222222222222);
  618. // if (payType && (payType == 'W01' || payType == 'U01' ||
  619. // payType == 'A01' || payType == 'S01'
  620. // )) {
  621. // console.log(generateOrderData, 321);
  622. // // 订单详情接口
  623. // this.qrcodeurl = generateOrderData.url
  624. // appDetail({
  625. // id: generateOrderData.id
  626. // }).then(res => {
  627. // uni.hideLoading();
  628. // this.qrcodeshow = true
  629. // this.qrcodeData = res.data
  630. // console.log(res.data);
  631. // })
  632. // } else {
  633. // uni.requestPayment({
  634. // provider: "wxpay",
  635. // appId: generateOrderData.appId,
  636. // timeStamp: generateOrderData.timeStamp,
  637. // nonceStr: generateOrderData.nonceStr,
  638. // package: generateOrderData.package,
  639. // signType: generateOrderData.signType,
  640. // paySign: generateOrderData.paySign,
  641. // success(res) {
  642. // uni.showToast({
  643. // title: '支付成功',
  644. // mask: true,
  645. // duration: 2000
  646. // });
  647. // setTimeout(function() {
  648. // uni.hideLoading();
  649. // // this_.refresh(res.data.data.id)
  650. // }, 1000);
  651. // },
  652. // fail(e) {
  653. // console.log(22222222);
  654. // uni.showToast({
  655. // title: "支付失败",
  656. // icon: 'none',
  657. // mask: true
  658. // });
  659. // setTimeout(function() {
  660. // uni.hideLoading();
  661. // // this_.refresh(res.data.id)
  662. // }, 1000);
  663. // }
  664. // })
  665. // }
  666. // }
  667. // })
  668. // }).catch(err => {
  669. // uni.hideLoading();
  670. // })
  671. // }
  672. // })
  673. }
  674. },
  675. radioGroupChange(e) {
  676. this.radiovalue = e
  677. if (e.length == 0) {
  678. this.companyValue = []
  679. } else {
  680. for (let li of this.dataList) {
  681. if (!this.companyValue.includes(li.name)) {
  682. this.companyValue.push(li.name)
  683. }
  684. }
  685. }
  686. this.inventoryfun(this.dataList)
  687. this.statistics()
  688. },
  689. statistics(val, index, ind) {
  690. console.log(val, index, ind)
  691. if (val) {
  692. this.dataList[index].list[ind].goodsNum = val.value
  693. }
  694. let data = []
  695. // for (let item of this.companyValue) {
  696. // for (let ite of this.dataList) {
  697. // if (item == ite.name) {
  698. // for (let it of ite.list) {
  699. // data.push(it)
  700. // }
  701. // }
  702. // }
  703. // }、
  704. for (let item of this.companyValue) {
  705. for (let ite of this.dataList) {
  706. if (item == ite.name) {
  707. data.push({
  708. name: item,
  709. list: ite.list
  710. })
  711. }
  712. }
  713. }
  714. this.totalPrice = 0
  715. this.totalFreight = 0
  716. let num = 0
  717. for (let item of data) {
  718. let num1 = 0
  719. for (let items of item.list) {
  720. this.totalPrice += Number(items.price) * Number(items.goodsNum)
  721. num += Number(items.goodsNum)
  722. num1 += Number(items.goodsNum)
  723. }
  724. if (num1 == 1) {
  725. this.totalFreight += this.freight ? Number(this.freight) : 5
  726. }
  727. }
  728. /* if(num>1){
  729. this.totalFreight = 0
  730. } */
  731. this.totalFreight = this.totalFreight.toFixed(2)
  732. this.totalPrice = this.totalPrice
  733. this.selectedProduct = data
  734. },
  735. companyChange(n) {
  736. this.companyValue = n
  737. this.inventoryfun(this.dataList)
  738. }
  739. }
  740. }
  741. </script>
  742. <style lang="scss" scoped>
  743. .collection {
  744. background-color: #fff;
  745. padding: 20rpx 40rpx 20rpx 20rpx;
  746. border-radius: 20rpx;
  747. margin-top: 20rpx;
  748. }
  749. .goods {
  750. width: 100%;
  751. margin-left: 20rpx;
  752. height: 200rpx;
  753. display: grid;
  754. align-content: space-between;
  755. .price {
  756. display: flex;
  757. justify-content: space-between !important;
  758. margin-top: 20rpx;
  759. align-items: center;
  760. view:nth-child(1) {
  761. color: #FD4B09;
  762. font-size: 40rpx;
  763. }
  764. }
  765. }
  766. .submitBar {
  767. position: fixed;
  768. bottom: calc(50px + env(safe-area-inset-bottom));
  769. background-color: #fff;
  770. width: 100%;
  771. z-index: 10;
  772. .bar_view {
  773. display: flex;
  774. justify-content: space-between;
  775. align-items: center;
  776. // padding: 10rpx;
  777. }
  778. }
  779. .redbutton {
  780. background-color: #FD4B09;
  781. height: 120rpx;
  782. line-height: 120rpx;
  783. width: 240rpx;
  784. text-align: center;
  785. }
  786. .lvbutton {
  787. background-color: #4c9e44;
  788. height: 120rpx;
  789. line-height: 120rpx;
  790. width: 160rpx;
  791. text-align: center;
  792. }
  793. </style>