shoppingCart.vue 31 KB

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