shoppingCart.vue 27 KB

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