shoppingCart.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. <template>
  2. <view v-if="checkStatus == '通过'">
  3. <view style="width: 100%;height: 155rpx;background: #FFFFFF;display: flex;align-items: center;" v-if="!editDel"
  4. @click="clickAddress">
  5. <view>
  6. <view style="font-size: 28rpx;color: #3B3B3B;font-weight: 400;display: flex;align-items: center;">
  7. <image src="/static/images/tabBar/1061@2x.png"
  8. style="width: 25rpx;height: 30rpx;margin-left: 34rpx;margin-right: 2rpx;" mode="scaleToFill">
  9. <text>{{addres.contacts}}</text>
  10. <text style="margin-left: 35rpx;">{{addres.tel}}</text>
  11. </view>
  12. <view style="font-size: 26rpx;color:#989898;font-weight: 400;margin-top: 22rpx;margin-left: 61rpx;">
  13. <text>{{addres.belongtoarea + addres.detailedAddress}}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <scroll-view scroll-y="true" style="max-height: 68vh;">
  18. <u-checkbox-group v-model="companyValue" placement="column" @change="companyChange" :size='15'>
  19. <view class="card" v-for="(item,index) in dataList" :key="index">
  20. <view style="margin-left: 50rpx;">
  21. <u-checkbox activeColor="#E75F37" shape="circle" :customStyle="{marginBottom: '8px'}"
  22. :label="item.name" :name="item.name" labelSize="28rpx" labelColor='#3B3B3B'></u-checkbox>
  23. </view>
  24. <view style="background: #FCF7F5;padding: 30rpx 30rpx;">
  25. <view style="margin:15rpx 0 15rpx 20rpx;display: flex;align-items: center;"
  26. v-for="(ite,ind) in item.list" :key="ind">
  27. <view>
  28. <image v-for="(li,inde) in ite.filesList" :key="inde" v-if="li.version === '0'"
  29. :src="li.url" style="width: 200rpx;height: 200rpx;border-radius: 20rpx;">
  30. </image>
  31. </view>
  32. <view style="width: 100%;margin-left: 8rpx ;">
  33. <view style="display: flex;justify-content: space-between;">
  34. <u--text :text="ite.goodsName" size="24rpx" color='#797979' lines="2"></u--text>
  35. <u-icon name="trash" size="40rpx" color='#C9C9C9'
  36. @click="deleteGoods(ite.id)"></u-icon>
  37. </view>
  38. <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
  39. <view style="color: #E75F37;font-size: 32rpx;">¥{{ite.price}}</view>
  40. <view v-if="!editDel">
  41. <u-number-box v-model="ite.goodsNum" :min="1" buttonSize="53rpx" color="#414141"
  42. bgColor="#FCF7F5" iconStyle="color:#A4A4A4"
  43. @change="(val)=>{statistics(val,index,ind)}"></u-number-box>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </u-checkbox-group>
  51. </scroll-view>
  52. <view class="submitBar">
  53. <view style="margin:20rpx 47rpx;">
  54. <view v-if="!editDel"
  55. style="display: flex;justify-content: space-between;align-items: flex-end;padding: 28rpx 0 28rpx 28rpx;">
  56. <u-checkbox-group v-model="radiovalue" placement="column" @change="radioGroupChange" :size='15'>
  57. <u-checkbox label="全选" name="全选" activeColor="#E75F37" shape="circle" labelSize="28rpx"
  58. labelColor='#3B3B3B'></u-checkbox>
  59. </u-checkbox-group>
  60. <view style="font-size: 24rpx;">合计:<text style="color: #E75F37;">¥</text><text
  61. style="font-size: 42rpx;color: #E75F37;">{{totalPrice}}</text></view>
  62. </view>
  63. <view style="height: 2rpx;width: 100%;background: #EEEEEE;">
  64. </view>
  65. <view
  66. style="display: flex;justify-content:space-between;align-items: center;padding: 28rpx 0 28rpx 28rpx;">
  67. <view v-if="!editDel" style="font-size: 24rpx;">
  68. <view style="color:#A3A3A3">运费:<text style="color: #E75F37;">¥{{totalFreight}}</text></view>
  69. </view>
  70. <view style="display: flex;">
  71. <view class="left-btn" v-if="!editDel" @click="submit('W01')">
  72. 他人代付</view>
  73. <view class="right-btn" v-if="!editDel" @click="submit()">立即支付
  74. </view>
  75. </view>
  76. </view>
  77. <view style="height: 2rpx;width: 100%;background: #EEEEEE;">
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. shoppingCartList,
  86. generateOrder,
  87. generateOrderLimit,
  88. shoppingCartUpdate,
  89. getCorpsAddr,
  90. paramserviceDetail,
  91. getParamservice,
  92. isProcurement,
  93. generateOrderShare
  94. } from '@/api/tabBar/shoppingCart.js'
  95. import {
  96. registerRuntimeCompiler
  97. } from "vue"
  98. import {
  99. details
  100. } from '@/api/views/personalInformation/index.js'
  101. import {
  102. appDetail
  103. } from '@/api/views/salesSlip/index.js'
  104. import {
  105. activityList
  106. } from '@/api/tabBar/activity.js'
  107. export default {
  108. data() {
  109. return {
  110. qrcodeshow: false, // 二维码弹窗
  111. qrcodeData: [], // 二维码数据
  112. qrcodeurl: '', // 二维码参数
  113. editDel: false,
  114. radiovalue: [],
  115. companyValue: [],
  116. dataList: [],
  117. companyValueLength: 0,
  118. selectedProduct: [],
  119. totalPrice: 0.00,
  120. totalFreight: 0.00,
  121. addres: {},
  122. checkStatus: null,
  123. adminShow: false,
  124. inventoryShow: false,
  125. inventoryContent: '',
  126. freight: 5,
  127. }
  128. },
  129. watch: {
  130. companyValue() {
  131. if (this.companyValue.length != 0 || this.companyValueLength != 0) {
  132. if (this.companyValue.length == this.companyValueLength) {
  133. this.radiovalue = ["全选"]
  134. } else {
  135. this.radiovalue = []
  136. }
  137. }
  138. this.statistics()
  139. }
  140. },
  141. onShow() {
  142. this.getUpdate()
  143. activityList({
  144. current: 1,
  145. size: 10,
  146. status: 1
  147. }).then(res => {
  148. uni.setTabBarBadge({
  149. index: 1, // tabIndex,tabBar的哪一项,从0开始
  150. text: res.data.total.toString() // 显示的文本,超过 99 显示成 “…”
  151. })
  152. })
  153. if (uni.getStorageSync('userInfo').tenant_id == '000000') {
  154. this.adminShow = true
  155. return
  156. }
  157. // 获取审核状态
  158. details().then(res => {
  159. this.checkStatus = res.data.checkStatus
  160. uni.setStorageSync('checkStatus', res.data.checkStatus);
  161. console.log(1111111)
  162. if (this.checkStatus != '通过') {
  163. uni.showToast({
  164. title: "当前用户未授权,请联系客服",
  165. icon: "none",
  166. mask: true
  167. });
  168. // uni.switchTab({
  169. // url:'/pages/tabBar/home'
  170. // })
  171. // return
  172. }
  173. })
  174. this.editDel = false
  175. this.companyValue = []
  176. uni.showLoading({
  177. title: '加载中',
  178. mask: true
  179. });
  180. shoppingCartList({
  181. whetherIntegral: '0'
  182. }).then(res => {
  183. this.dataList = res.data
  184. this.companyValueLength = this.dataList.length
  185. if (res.data.length) {
  186. this.companyChange([res.data[0].name])
  187. }
  188. this.inventoryfun(res.data)
  189. let num = 0
  190. res.data.forEach(e => {
  191. console.log(e.list)
  192. num = num + e.list.length
  193. })
  194. uni.setTabBarBadge({
  195. index: 3, // tabIndex,tabBar的哪一项,从0开始
  196. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  197. })
  198. uni.hideLoading();
  199. }).catch(err => {
  200. uni.hideLoading();
  201. })
  202. getCorpsAddr().then(res => {
  203. this.addres = res.data
  204. })
  205. // 支付成功之后的回调
  206. let options = wx.getEnterOptionsSync();
  207. if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3') {
  208. // 代表从收银台小程序返回
  209. let extraData = options.referrerInfo.extraData;
  210. if (!extraData) {
  211. // "当前通过物理按键返回,未接收到返参,建议自行查询交易结果";
  212. console.log('当前通过物理按键返回,未接收到返参,建议自行查询交易结果');
  213. } else {
  214. if (extraData.code == 'success') {
  215. // "支付成功";
  216. } else if (extraData.code == 'cancel') {
  217. // "支付已取消";
  218. console.log(extraData, '支付已取消');
  219. } else {
  220. console.log(extraData, '失败');
  221. // "支付失败:" + extraData.errmsg;
  222. }
  223. }
  224. }
  225. isProcurement({
  226. "param": "freight"
  227. }).then(res => {
  228. // res.data.data === '1'
  229. this.freight = res.data
  230. })
  231. },
  232. methods: {
  233. getUpdate() {
  234. const updateManager = uni.getUpdateManager();
  235. updateManager.onCheckForUpdate(function(res) {
  236. // 请求完新版本信息的回调
  237. if (res.hasUpdate) {
  238. updateManager.onUpdateReady(function() {
  239. uni.showModal({
  240. title: '更新提示',
  241. content: '新版本已经准备好,是否重启应用?',
  242. success: function(res) {
  243. if (res.confirm) {
  244. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  245. updateManager.applyUpdate();
  246. }
  247. }
  248. });
  249. });
  250. updateManager.onUpdateFailed(function() {
  251. // 新的版本下载失败
  252. uni.showModal({
  253. title: '已经有新版本了哟~',
  254. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  255. });
  256. });
  257. }
  258. });
  259. },
  260. // 库存弹窗
  261. inventoryfun(arr) {
  262. let sum = ''
  263. arr.map((item, index) => {
  264. item.list.map(ite => {
  265. if (Number(ite.goodsNum) > Number(ite.inventory)) {
  266. console.log(ite)
  267. sum += `${ite.goodsName} 的库存数量为${ite.inventory}<br>`
  268. }
  269. return ite
  270. })
  271. return item
  272. })
  273. if (sum != '') {
  274. this.inventoryContent = sum + '请修正数量后重新结算'
  275. this.inventoryShow = true
  276. return true
  277. }
  278. return false
  279. },
  280. // admin确认
  281. adminConfirm() {
  282. uni.clearStorageSync();
  283. uni.redirectTo({
  284. url: '/pages/login/login'
  285. })
  286. },
  287. // admin取消
  288. adminCancel() {
  289. uni.switchTab({
  290. url: '/pages/tabBar/home'
  291. })
  292. },
  293. // 弹窗关闭
  294. qrcodeclose() {
  295. this.qrcodeshow = false
  296. uni.showLoading({
  297. title: '加载中',
  298. mask: true
  299. });
  300. // 详情调用
  301. shoppingCartList({
  302. whetherIntegral: '0'
  303. }).then(res => {
  304. this.dataList = res.data
  305. this.companyValueLength = this.dataList.length
  306. uni.hideLoading();
  307. }).catch(err => {
  308. uni.hideLoading();
  309. })
  310. },
  311. clickAddress() {
  312. this.$u.route('/pages/views/personalInformation/addressManagement');
  313. },
  314. getList() {
  315. uni.showLoading({
  316. title: '加载中',
  317. mask: true
  318. });
  319. shoppingCartList({
  320. whetherIntegral: '0'
  321. }).then(res => {
  322. this.dataList = res.data
  323. this.companyValueLength = this.dataList.length
  324. if (res.data.length) {
  325. this.companyChange([res.data[0].name])
  326. }
  327. let num = 0
  328. res.data.forEach(e => {
  329. num = num + e.list.length
  330. })
  331. uni.setTabBarBadge({
  332. index: 3, // tabIndex,tabBar的哪一项,从0开始
  333. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  334. })
  335. uni.hideLoading();
  336. }).catch(err => {
  337. uni.hideLoading();
  338. })
  339. },
  340. deleteGoods(val) {
  341. let _this = this
  342. uni.showModal({
  343. title: '提示',
  344. content: '是否删除?',
  345. success: function(res) {
  346. if (res.confirm) {
  347. uni.showLoading({
  348. title: '加载中',
  349. mask: true
  350. });
  351. shoppingCartUpdate({
  352. ids: val
  353. }).then(res => {
  354. uni.showToast({
  355. title: "删除成功",
  356. icon: 'none'
  357. });
  358. _this.getList()
  359. // this.editDel = false
  360. _this.companyValue = []
  361. }).catch(err => {
  362. uni.hideLoading();
  363. })
  364. } else if (res.cancel) {
  365. console.log('用户点击取消');
  366. }
  367. }
  368. });
  369. },
  370. deleteShopping() {
  371. if (this.selectedProduct.length == 0) {
  372. uni.showToast({
  373. title: "请先选择要支付的商品",
  374. icon: 'none'
  375. });
  376. return
  377. }
  378. let data = []
  379. for (let item of this.companyValue) {
  380. for (let ite of this.dataList) {
  381. if (item == ite.name) {
  382. for (let it of ite.list) {
  383. data.push(it.id)
  384. }
  385. }
  386. }
  387. }
  388. uni.showLoading({
  389. title: '加载中',
  390. mask: true
  391. });
  392. shoppingCartUpdate({
  393. ids: data.join(',')
  394. }).then(res => {
  395. uni.showToast({
  396. title: "删除成功",
  397. icon: 'none'
  398. });
  399. this.editDel = false
  400. this.companyValue = []
  401. shoppingCartList({
  402. whetherIntegral: '0'
  403. }).then(res => {
  404. this.dataList = res.data
  405. this.companyValueLength = this.dataList.length
  406. uni.hideLoading();
  407. }).catch(err => {
  408. uni.hideLoading();
  409. })
  410. }).catch(err => {
  411. uni.hideLoading();
  412. })
  413. },
  414. // 立即支付
  415. submit() {
  416. if (this.selectedProduct.length == 0) {
  417. uni.showToast({
  418. title: "请先选择要支付的商品",
  419. icon: 'none'
  420. });
  421. return
  422. }
  423. if (this.inventoryfun(this.dataList)) {
  424. return
  425. }
  426. isProcurement({
  427. "param": "whether.open.share"
  428. }).then(res => {
  429. if (res.data == 1) {
  430. //共享支付流程
  431. this.sharedPayment()
  432. } else {
  433. //正常支付流程
  434. this.normalPayment()
  435. }
  436. })
  437. },
  438. //原来支付流程
  439. async normalPayment() {
  440. if (this.companyValue.length > 0) {
  441. let data = []
  442. for (let item of this.companyValue) {
  443. for (let ite of this.dataList) {
  444. if (item == ite.name) {
  445. data.push({
  446. name: item,
  447. list: ite.list
  448. })
  449. }
  450. }
  451. }
  452. uni.showLoading({
  453. title: '加载中',
  454. mask: true
  455. });
  456. // 判断是否用额度支付
  457. const personRef = await details()
  458. const totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
  459. // 是否开通额度
  460. getParamservice(1, 10, {
  461. paramKey: 'WeChat.shipping.notification'
  462. }).then(res => {
  463. console.log(res)
  464. if (res.data.records.length > 0) {
  465. let payType = res.data.records[0].paramValue == 1 ? 'W11' : 'W06'
  466. if (personRef.data.ifLimitAmount == 1) {
  467. // 额度是否够用
  468. if (Number(personRef.data.limitAmount >= totalPrice)) {
  469. // 额度
  470. // this.payType='W06'
  471. generateOrderLimit({
  472. payType: res.data.records[0].paramValue == 1 ? 'W11' : 'W06',
  473. address: this.addres.belongtoarea + this.addres
  474. .detailedAddress,
  475. list: data,
  476. }).then(res => {
  477. uni.hideLoading();
  478. uni.showToast({
  479. title: '支付成功',
  480. mask: true,
  481. duration: 2000
  482. });
  483. setTimeout(function() {
  484. uni.hideLoading({
  485. noConflict: true
  486. });
  487. }, 1000);
  488. // 详情调用
  489. shoppingCartList({
  490. whetherIntegral: '0'
  491. }).then(res => {
  492. this.dataList = res.data
  493. this.companyValueLength = this.dataList.length
  494. }).catch(err => {})
  495. })
  496. return
  497. }
  498. }
  499. // 正常支付
  500. generateOrder({
  501. payType: res.data.records[0].paramValue == 1 ? 'W11' : 'W06',
  502. address: this.addres.belongtoarea + this.addres.detailedAddress,
  503. list: data,
  504. }).then(res => {
  505. let generateOrderData = res.data
  506. paramserviceDetail({
  507. paramKey: 'cashier.payment'
  508. }).then(res => {
  509. let paramservice = res.data
  510. // paramservice.paramValue=0
  511. // 判断是调支付台的接口还是微信支付的接口
  512. if (paramservice && paramservice.paramValue == '1') {
  513. console.log(222211111111);
  514. // uni.hideLoading();
  515. // uni.requestPayment({
  516. // provider: "wxpay",
  517. // appId: generateOrderData.appId,
  518. // timeStamp: generateOrderData.timeStamp,
  519. // nonceStr: generateOrderData.nonceStr,
  520. // package: generateOrderData.package,
  521. // signType: generateOrderData.signType,
  522. // paySign: generateOrderData.paySign,
  523. // success(res) {
  524. // uni.showToast({
  525. // title: '支付成功',
  526. // mask: true,
  527. // duration: 2000
  528. // });
  529. // setTimeout(function() {
  530. // uni.hideLoading();
  531. // // this_.refresh(res.data.data.id)
  532. // }, 1000);
  533. // },
  534. // fail(e) {
  535. // console.log(e,11111111);
  536. // uni.showToast({
  537. // title: "支付失败",
  538. // icon: 'none',
  539. // mask: true
  540. // });
  541. // setTimeout(function() {
  542. // uni.hideLoading();
  543. // // this_.refresh(res.data.id)
  544. // }, 1000);
  545. // }
  546. // })
  547. let obj = {
  548. appId: 'wxef277996acc166c3',
  549. extraData: {
  550. cusid: generateOrderData.cusid,
  551. appid: generateOrderData.appid,
  552. orgid: generateOrderData.orgid,
  553. version: generateOrderData.version,
  554. trxamt: generateOrderData.trxamt,
  555. reqsn: generateOrderData.reqsn,
  556. notify_url: generateOrderData.notify_url,
  557. body: generateOrderData.body,
  558. remark: generateOrderData.remark,
  559. validtime: generateOrderData.validtime,
  560. limit_pay: generateOrderData.limit_pay,
  561. randomstr: generateOrderData.randomstr,
  562. paytype: generateOrderData.paytype,
  563. signtype: generateOrderData.signtype,
  564. sign: generateOrderData.sign,
  565. },
  566. }
  567. console.log(obj);
  568. if (!generateOrderData.reqsn) {
  569. uni.showToast({
  570. title: '当前订单号为空,请联系供应商!!!',
  571. icon: 'none',
  572. mask: true,
  573. duration: 2000
  574. });
  575. // 详情调用
  576. shoppingCartList({
  577. whetherIntegral: '0'
  578. }).then(res => {
  579. this.dataList = res.data
  580. this.companyValueLength = this.dataList
  581. .length
  582. }).catch(err => {})
  583. return
  584. }
  585. wx.openEmbeddedMiniProgram({
  586. appId: 'wxef277996acc166c3',
  587. extraData: {
  588. cusid: generateOrderData.cusid,
  589. appid: generateOrderData.appid,
  590. orgid: generateOrderData.orgid,
  591. version: generateOrderData.version,
  592. trxamt: generateOrderData.trxamt,
  593. reqsn: generateOrderData.reqsn,
  594. notify_url: generateOrderData
  595. .notify_url,
  596. body: generateOrderData.body,
  597. remark: generateOrderData.remark,
  598. validtime: generateOrderData.validtime,
  599. // limit_pay: generateOrderData.limit_pay,
  600. limit_pay: "",
  601. randomstr: generateOrderData.randomstr,
  602. paytype: generateOrderData.paytype,
  603. signtype: generateOrderData.signtype,
  604. sign: generateOrderData.sign,
  605. },
  606. success: (a) => {
  607. uni.hideLoading();
  608. },
  609. fail: (err) => {
  610. uni.hideLoading();
  611. }
  612. })
  613. } else {
  614. console.log(2222222222222222);
  615. if (payType && (payType == 'W01' || payType == 'U01' ||
  616. payType == 'A01' || payType == 'S01'
  617. )) {
  618. console.log(generateOrderData, 321);
  619. // 订单详情接口
  620. this.qrcodeurl = generateOrderData.url
  621. appDetail({
  622. id: generateOrderData.id
  623. }).then(res => {
  624. uni.hideLoading();
  625. this.qrcodeshow = true
  626. this.qrcodeData = res.data
  627. console.log(res.data);
  628. })
  629. } else {
  630. uni.requestPayment({
  631. provider: "wxpay",
  632. appId: generateOrderData.appId,
  633. timeStamp: generateOrderData.timeStamp,
  634. nonceStr: generateOrderData.nonceStr,
  635. package: generateOrderData.package,
  636. signType: generateOrderData.signType,
  637. paySign: generateOrderData.paySign,
  638. success(res) {
  639. uni.showToast({
  640. title: '支付成功',
  641. mask: true,
  642. duration: 2000
  643. });
  644. setTimeout(function() {
  645. uni.hideLoading({
  646. noConflict: true
  647. });
  648. // this_.refresh(res.data.data.id)
  649. }, 1000);
  650. },
  651. fail(e) {
  652. console.log(22222222);
  653. uni.showToast({
  654. title: "支付失败",
  655. icon: 'none',
  656. mask: true
  657. });
  658. setTimeout(function() {
  659. uni.hideLoading({
  660. noConflict: true
  661. });
  662. // this_.refresh(res.data.id)
  663. }, 1000);
  664. }
  665. })
  666. }
  667. }
  668. })
  669. }).catch(err => {
  670. uni.hideLoading();
  671. })
  672. }
  673. })
  674. }
  675. },
  676. sharedPayment() {
  677. if (this.companyValue.length > 0) {
  678. let data = []
  679. for (let item of this.companyValue) {
  680. for (let ite of this.dataList) {
  681. if (item == ite.name) {
  682. data = data.concat(ite.list)
  683. }
  684. }
  685. }
  686. let obj = {
  687. address: this.addres.belongtoarea + this.addres.detailedAddress,
  688. shoppingCartList: data,
  689. }
  690. uni.showLoading({
  691. title: '加载中',
  692. mask: true
  693. });
  694. generateOrderShare(obj).then(res => {
  695. // res.data.type=0
  696. let generateOrderData = res.data
  697. //小程序支付
  698. if (res.data.type == '0') {
  699. uni.requestPayment({
  700. provider: "wxpay",
  701. appId: generateOrderData.appId,
  702. timeStamp: generateOrderData.timeStamp,
  703. nonceStr: generateOrderData.nonceStr,
  704. package: generateOrderData.package,
  705. signType: generateOrderData.signType,
  706. paySign: generateOrderData.paySign,
  707. success(res) {
  708. uni.showToast({
  709. title: '支付成功',
  710. mask: true,
  711. duration: 2000
  712. });
  713. setTimeout(function() {
  714. uni.hideLoading({
  715. noConflict: true
  716. });
  717. // this_.refresh(res.data.data.id)
  718. }, 1000);
  719. },
  720. fail(e) {
  721. console.log(22222222);
  722. uni.showToast({
  723. title: "支付失败",
  724. icon: 'none',
  725. mask: true
  726. });
  727. setTimeout(function() {
  728. uni.hideLoading({
  729. noConflict: true
  730. });
  731. // this_.refresh(res.data.id)
  732. }, 1000);
  733. }
  734. })
  735. }
  736. //收银台支付 'w06'
  737. if (res.data.type == '1') {
  738. wx.openEmbeddedMiniProgram({
  739. appId: 'wxef277996acc166c3',
  740. extraData: {
  741. cusid: generateOrderData.cusid,
  742. appid: generateOrderData.appid,
  743. orgid: generateOrderData.orgid,
  744. version: generateOrderData.version,
  745. trxamt: generateOrderData.trxamt,
  746. reqsn: generateOrderData.reqsn,
  747. notify_url: generateOrderData.notify_url,
  748. body: generateOrderData.body,
  749. remark: generateOrderData.remark,
  750. validtime: generateOrderData.validtime,
  751. // limit_pay: generateOrderData.limit_pay,
  752. limit_pay: "",
  753. randomstr: generateOrderData.randomstr,
  754. paytype: generateOrderData.paytype,
  755. signtype: generateOrderData.signtype,
  756. sign: generateOrderData.sign,
  757. },
  758. success: (a) => {
  759. uni.hideLoading();
  760. },
  761. fail: (err) => {
  762. uni.hideLoading();
  763. }
  764. })
  765. }
  766. //额度支付
  767. if (res.data.type == '2') {
  768. details().then(res => {
  769. const personRef = res
  770. const totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
  771. // 是否开通额度
  772. isProcurement({
  773. "param": "WeChat.shipping.notification"
  774. }).then(res => {
  775. if (personRef.data.ifLimitAmount == 1) {
  776. // 额度是否够用
  777. if (Number(personRef.data.limitAmount >= totalPrice)) {
  778. // 额度
  779. // this.payType='W06'
  780. generateOrderLimit({
  781. payType: res.data == 1 ? 'W11' : 'W06',
  782. address: this.addres.belongtoarea +
  783. this.addres
  784. .detailedAddress,
  785. list: data,
  786. }).then(res => {
  787. uni.hideLoading();
  788. uni.showToast({
  789. title: '支付成功',
  790. mask: true,
  791. duration: 2000
  792. });
  793. setTimeout(function() {
  794. uni.hideLoading({
  795. noConflict: true
  796. });
  797. }, 1000);
  798. // 详情调用
  799. shoppingCartList({
  800. whetherIntegral: '0'
  801. }).then(res => {
  802. this.dataList = res.data
  803. this.companyValueLength =
  804. this.dataList.length
  805. }).catch(err => {})
  806. })
  807. }
  808. }
  809. })
  810. })
  811. }
  812. })
  813. }
  814. },
  815. radioGroupChange(e) {
  816. this.radiovalue = e
  817. if (e.length == 0) {
  818. this.companyValue = []
  819. } else {
  820. for (let li of this.dataList) {
  821. if (!this.companyValue.includes(li.name)) {
  822. this.companyValue.push(li.name)
  823. }
  824. }
  825. }
  826. this.inventoryfun(this.dataList)
  827. this.statistics()
  828. },
  829. radioGroupChange(e) {
  830. this.radiovalue = e
  831. if (e.length == 0) {
  832. this.companyValue = []
  833. } else {
  834. for (let li of this.dataList) {
  835. if (!this.companyValue.includes(li.name)) {
  836. this.companyValue.push(li.name)
  837. }
  838. }
  839. }
  840. this.inventoryfun(this.dataList)
  841. this.statistics()
  842. },
  843. statistics(val, index, ind) {
  844. console.log(val, index, ind)
  845. if (val) {
  846. this.dataList[index].list[ind].goodsNum = val.value
  847. }
  848. let data = []
  849. // for (let item of this.companyValue) {
  850. // for (let ite of this.dataList) {
  851. // if (item == ite.name) {
  852. // for (let it of ite.list) {
  853. // data.push(it)
  854. // }
  855. // }
  856. // }
  857. // }、
  858. for (let item of this.companyValue) {
  859. for (let ite of this.dataList) {
  860. if (item == ite.name) {
  861. data.push({
  862. name: item,
  863. list: ite.list
  864. })
  865. }
  866. }
  867. }
  868. this.totalPrice = 0
  869. this.totalFreight = 0
  870. let num = 0
  871. for (let item of data) {
  872. let num1 = 0
  873. for (let items of item.list) {
  874. this.totalPrice += Number(items.price) * Number(items.goodsNum)
  875. num += Number(items.goodsNum)
  876. num1 += Number(items.goodsNum)
  877. }
  878. if (num1 == 1) {
  879. this.totalFreight += this.freight ? Number(this.freight) : 5
  880. this.totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
  881. }
  882. }
  883. /* if(num>1){
  884. this.totalFreight = 0
  885. } */
  886. this.totalFreight = this.totalFreight.toFixed(2)
  887. this.totalPrice = this.totalPrice.toFixed(2)
  888. this.selectedProduct = data
  889. },
  890. companyChange(n) {
  891. this.companyValue = n
  892. this.inventoryfun(this.dataList)
  893. }
  894. }
  895. }
  896. </script>
  897. <style lang="scss" scoped>
  898. .card {
  899. background: #FFFFFF;
  900. padding: 32rpx;
  901. margin: 20rpx 0;
  902. ::v-deep .u-checkbox__icon-wrap {
  903. border-color: #E75F37 !important;
  904. }
  905. ::v-deep .u-number-box {
  906. border: 2rpx #E1E1E1 solid;
  907. border-radius: 8rpx;
  908. }
  909. ::v-deep .u-number-box__minus {
  910. border-right: 2rpx #E1E1E1 solid;
  911. }
  912. ::v-deep .u-number-box__plus {
  913. border-left: 2rpx #E1E1E1 solid;
  914. }
  915. }
  916. .submitBar {
  917. position: fixed;
  918. bottom: 0;
  919. background-color: #fff;
  920. width: 100%;
  921. z-index: 10;
  922. ::v-deep .u-checkbox__icon-wrap {
  923. border-color: #E75F37 !important;
  924. }
  925. .left-btn {
  926. background-color: #FFEEE9;
  927. color: #E75F37;
  928. font-size: 26rpx;
  929. width: 160rpx;
  930. height: 65rpx;
  931. display: flex;
  932. justify-content: center;
  933. align-items: center;
  934. border-top-left-radius: 33rpx;
  935. border-bottom-left-radius: 33rpx;
  936. }
  937. .right-btn {
  938. background-color: #E75F37;
  939. color: #fff;
  940. font-size: 26rpx;
  941. width: 160rpx;
  942. height: 65rpx;
  943. display: flex;
  944. justify-content: center;
  945. align-items: center;
  946. border-top-right-radius: 33rpx;
  947. border-bottom-right-radius: 33rpx;
  948. }
  949. }
  950. </style>