shoppingCart.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  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. uni.showToast({
  447. title: '当前下单数量超出库存数量,请修改下单数量',
  448. icon: 'none',
  449. mask: true,
  450. duration: 2000
  451. });
  452. return
  453. }
  454. isProcurement({
  455. "param": "whether.open.share"
  456. }).then(res => {
  457. if (res.data == 1) {
  458. //共享支付流程
  459. this.sharedPayment()
  460. } else {
  461. //正常支付流程
  462. this.normalPayment()
  463. }
  464. })
  465. },
  466. //原来支付流程
  467. async normalPayment() {
  468. if (this.companyValue.length > 0) {
  469. let data = []
  470. for (let item of this.companyValue) {
  471. let ite = this.dataList.find(e => e.name === item)
  472. if (ite) {
  473. data.push({
  474. name: item,
  475. list: ite.list
  476. })
  477. }
  478. }
  479. uni.showLoading({
  480. title: '加载中',
  481. mask: true
  482. });
  483. // 判断是否用额度支付
  484. const personRef = await details()
  485. let latest = Number(personRef.data.recoveredBalance)
  486. let realRecoveredBalanceAmount = 0.0
  487. let useRecoveredBalance = false
  488. if (this.checkRecoveredBalance.length > 0) {
  489. let half = Number(this.totalPrice) / 2
  490. realRecoveredBalanceAmount = latest > half ? half : latest
  491. useRecoveredBalance = true
  492. }
  493. const totalPrice = Number(this.totalPrice) + Number(this.totalFreight) - Number(realRecoveredBalanceAmount)
  494. // 是否开通额度
  495. getParamservice(1, 10, {
  496. paramKey: 'WeChat.shipping.notification'
  497. }).then(res => {
  498. console.log(res)
  499. if (res.data.records.length > 0) {
  500. let payType = res.data.records[0].paramValue == 1 ? 'W11' : 'W06'
  501. if (personRef.data.ifLimitAmount == 1) {
  502. // 额度是否够用
  503. if (Number(personRef.data.limitAmount >= totalPrice)) {
  504. // 额度
  505. // this.payType='W06'
  506. generateOrderLimit({
  507. payType: res.data.records[0].paramValue == 1 ? 'W11' : 'W06',
  508. address: this.addres.belongtoarea + this.addres
  509. .detailedAddress,
  510. list: data,
  511. }).then(res => {
  512. uni.hideLoading();
  513. uni.showToast({
  514. title: '支付成功',
  515. mask: true,
  516. duration: 2000
  517. });
  518. setTimeout(function() {
  519. uni.hideLoading({
  520. noConflict: true
  521. });
  522. }, 1000);
  523. // 详情调用
  524. shoppingCartList({
  525. whetherIntegral: '0'
  526. }).then(res => {
  527. this.dataList = res.data
  528. this.companyValueLength = this.dataList.length
  529. }).catch(err => {})
  530. })
  531. return
  532. }
  533. }
  534. // 正常支付
  535. generateOrder({
  536. payType: res.data.records[0].paramValue == 1 ? 'W11' : 'W06',
  537. address: this.addres.belongtoarea + this.addres.detailedAddress,
  538. list: data,
  539. useRecoveredBalance: this.checkRecoveredBalance.length > 0
  540. }).then(res => {
  541. let generateOrderData = res.data
  542. paramserviceDetail({
  543. paramKey: 'cashier.payment'
  544. }).then(res => {
  545. let paramservice = res.data
  546. // paramservice.paramValue=0
  547. // 判断是调支付台的接口还是微信支付的接口
  548. if (paramservice && paramservice.paramValue == '1') {
  549. console.log(222211111111);
  550. // uni.hideLoading();
  551. // uni.requestPayment({
  552. // provider: "wxpay",
  553. // appId: generateOrderData.appId,
  554. // timeStamp: generateOrderData.timeStamp,
  555. // nonceStr: generateOrderData.nonceStr,
  556. // package: generateOrderData.package,
  557. // signType: generateOrderData.signType,
  558. // paySign: generateOrderData.paySign,
  559. // success(res) {
  560. // uni.showToast({
  561. // title: '支付成功',
  562. // mask: true,
  563. // duration: 2000
  564. // });
  565. // setTimeout(function() {
  566. // uni.hideLoading();
  567. // // this_.refresh(res.data.data.id)
  568. // }, 1000);
  569. // },
  570. // fail(e) {
  571. // console.log(e,11111111);
  572. // uni.showToast({
  573. // title: "支付失败",
  574. // icon: 'none',
  575. // mask: true
  576. // });
  577. // setTimeout(function() {
  578. // uni.hideLoading();
  579. // // this_.refresh(res.data.id)
  580. // }, 1000);
  581. // }
  582. // })
  583. let obj = {
  584. appId: 'wxef277996acc166c3',
  585. extraData: {
  586. cusid: generateOrderData.cusid,
  587. appid: generateOrderData.appid,
  588. orgid: generateOrderData.orgid,
  589. version: generateOrderData.version,
  590. trxamt: generateOrderData.trxamt,
  591. reqsn: generateOrderData.reqsn,
  592. notify_url: generateOrderData.notify_url,
  593. body: generateOrderData.body,
  594. remark: generateOrderData.remark,
  595. validtime: generateOrderData.validtime,
  596. limit_pay: generateOrderData.limit_pay,
  597. randomstr: generateOrderData.randomstr,
  598. paytype: generateOrderData.paytype,
  599. signtype: generateOrderData.signtype,
  600. sign: generateOrderData.sign,
  601. },
  602. }
  603. console.log(obj);
  604. if (!generateOrderData.reqsn) {
  605. uni.showToast({
  606. title: '当前订单号为空,请联系供应商!!!',
  607. icon: 'none',
  608. mask: true,
  609. duration: 2000
  610. });
  611. // 详情调用
  612. shoppingCartList({
  613. whetherIntegral: '0'
  614. }).then(res => {
  615. this.dataList = res.data
  616. this.companyValueLength = this.dataList
  617. .length
  618. }).catch(err => {})
  619. return
  620. }
  621. wx.openEmbeddedMiniProgram({
  622. appId: 'wxef277996acc166c3',
  623. extraData: {
  624. cusid: generateOrderData.cusid,
  625. appid: generateOrderData.appid,
  626. orgid: generateOrderData.orgid,
  627. version: generateOrderData.version,
  628. trxamt: generateOrderData.trxamt,
  629. reqsn: generateOrderData.reqsn,
  630. notify_url: generateOrderData
  631. .notify_url,
  632. body: generateOrderData.body,
  633. remark: generateOrderData.remark,
  634. validtime: generateOrderData.validtime,
  635. // limit_pay: generateOrderData.limit_pay,
  636. limit_pay: "",
  637. randomstr: generateOrderData.randomstr,
  638. paytype: generateOrderData.paytype,
  639. signtype: generateOrderData.signtype,
  640. sign: generateOrderData.sign,
  641. },
  642. success: (a) => {
  643. uni.hideLoading();
  644. },
  645. fail: (err) => {
  646. uni.hideLoading();
  647. }
  648. })
  649. } else {
  650. console.log(2222222222222222);
  651. if (payType && (payType == 'W01' || payType == 'U01' ||
  652. payType == 'A01' || payType == 'S01'
  653. )) {
  654. console.log(generateOrderData, 321);
  655. // 订单详情接口
  656. this.qrcodeurl = generateOrderData.url
  657. appDetail({
  658. id: generateOrderData.id
  659. }).then(res => {
  660. uni.hideLoading();
  661. this.qrcodeshow = true
  662. this.qrcodeData = res.data
  663. console.log(res.data);
  664. })
  665. } else {
  666. uni.requestPayment({
  667. provider: "wxpay",
  668. appId: generateOrderData.appId,
  669. timeStamp: generateOrderData.timeStamp,
  670. nonceStr: generateOrderData.nonceStr,
  671. package: generateOrderData.package,
  672. signType: generateOrderData.signType,
  673. paySign: generateOrderData.paySign,
  674. success(res) {
  675. uni.showToast({
  676. title: '支付成功',
  677. mask: true,
  678. duration: 2000
  679. });
  680. setTimeout(function() {
  681. uni.hideLoading({
  682. noConflict: true
  683. });
  684. // this_.refresh(res.data.data.id)
  685. }, 1000);
  686. },
  687. fail(e) {
  688. console.log(22222222);
  689. uni.showToast({
  690. title: "支付失败",
  691. icon: 'none',
  692. mask: true
  693. });
  694. setTimeout(function() {
  695. uni.hideLoading({
  696. noConflict: true
  697. });
  698. // this_.refresh(res.data.id)
  699. }, 1000);
  700. }
  701. })
  702. }
  703. }
  704. })
  705. }).catch(err => {
  706. uni.hideLoading();
  707. })
  708. }
  709. })
  710. }
  711. },
  712. sharedPayment() {
  713. if (this.companyValue.length > 0) {
  714. let data = []
  715. for (let item of this.companyValue) {
  716. let ite = this.dataList.find(e => e.name === item)
  717. if (ite) {
  718. data = data.concat(ite.list)
  719. }
  720. }
  721. let obj = {
  722. address: this.addres.belongtoarea + this.addres.detailedAddress,
  723. shoppingCartList: data,
  724. useRecoveredBalance: this.checkRecoveredBalance.length > 0
  725. }
  726. uni.showLoading({
  727. title: '加载中',
  728. mask: true
  729. });
  730. generateOrderShare(obj).then(res => {
  731. // res.data.type=0
  732. let generateOrderData = res.data
  733. //小程序支付
  734. if (res.data.type == '0') {
  735. uni.requestPayment({
  736. provider: "wxpay",
  737. appId: generateOrderData.appId,
  738. timeStamp: generateOrderData.timeStamp,
  739. nonceStr: generateOrderData.nonceStr,
  740. package: generateOrderData.package,
  741. signType: generateOrderData.signType,
  742. paySign: generateOrderData.paySign,
  743. success(res) {
  744. uni.showToast({
  745. title: '支付成功',
  746. mask: true,
  747. duration: 2000
  748. });
  749. setTimeout(function() {
  750. uni.hideLoading({
  751. noConflict: true
  752. });
  753. // this_.refresh(res.data.data.id)
  754. }, 1000);
  755. },
  756. fail(e) {
  757. console.log(22222222);
  758. uni.showToast({
  759. title: "支付失败",
  760. icon: 'none',
  761. mask: true
  762. });
  763. setTimeout(function() {
  764. uni.hideLoading({
  765. noConflict: true
  766. });
  767. // this_.refresh(res.data.id)
  768. }, 1000);
  769. }
  770. })
  771. }
  772. //收银台支付 'w06'
  773. if (res.data.type == '1') {
  774. wx.openEmbeddedMiniProgram({
  775. appId: 'wxef277996acc166c3',
  776. extraData: {
  777. cusid: generateOrderData.cusid,
  778. appid: generateOrderData.appid,
  779. orgid: generateOrderData.orgid,
  780. version: generateOrderData.version,
  781. trxamt: generateOrderData.trxamt,
  782. reqsn: generateOrderData.reqsn,
  783. notify_url: generateOrderData.notify_url,
  784. body: generateOrderData.body,
  785. remark: generateOrderData.remark,
  786. validtime: generateOrderData.validtime,
  787. // limit_pay: generateOrderData.limit_pay,
  788. limit_pay: "",
  789. randomstr: generateOrderData.randomstr,
  790. paytype: generateOrderData.paytype,
  791. signtype: generateOrderData.signtype,
  792. sign: generateOrderData.sign,
  793. },
  794. success: (a) => {
  795. uni.hideLoading();
  796. },
  797. fail: (err) => {
  798. uni.hideLoading();
  799. }
  800. })
  801. }
  802. //额度支付
  803. if (res.data.type == '2') {
  804. details().then(res => {
  805. const personRef = res
  806. const totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
  807. // 是否开通额度
  808. isProcurement({
  809. "param": "WeChat.shipping.notification"
  810. }).then(res => {
  811. if (personRef.data.ifLimitAmount == 1) {
  812. // 额度是否够用
  813. if (Number(personRef.data.limitAmount >= totalPrice)) {
  814. // 额度
  815. // this.payType='W06'
  816. generateOrderLimit({
  817. payType: res.data == 1 ? 'W11' : 'W06',
  818. address: this.addres.belongtoarea +
  819. this.addres
  820. .detailedAddress,
  821. list: data,
  822. }).then(res => {
  823. uni.hideLoading();
  824. uni.showToast({
  825. title: '支付成功',
  826. mask: true,
  827. duration: 2000
  828. });
  829. setTimeout(function() {
  830. uni.hideLoading({
  831. noConflict: true
  832. });
  833. }, 1000);
  834. // 详情调用
  835. shoppingCartList({
  836. whetherIntegral: '0'
  837. }).then(res => {
  838. this.dataList = res.data
  839. this.companyValueLength =
  840. this.dataList.length
  841. }).catch(err => {})
  842. })
  843. }
  844. }
  845. })
  846. })
  847. }
  848. })
  849. }
  850. },
  851. radioGroupChange(e) {
  852. this.radiovalue = e
  853. if (e.length == 0) {
  854. this.companyValue = []
  855. } else {
  856. for (let li of this.dataList) {
  857. if (!this.companyValue.includes(li.name)) {
  858. this.companyValue.push(li.name)
  859. }
  860. }
  861. }
  862. this.inventoryfun(this.dataList)
  863. this.statistics()
  864. },
  865. checkRecovered(e){
  866. console.info('e---------', e)
  867. this.checkRecoveredBalance = e
  868. },
  869. statistics(val, index, ind) {
  870. console.log(val, index, ind)
  871. if (val) {
  872. this.dataList[index].list[ind].goodsNum = val.value
  873. }
  874. let data = []
  875. // for (let item of this.companyValue) {
  876. // for (let ite of this.dataList) {
  877. // if (item == ite.name) {
  878. // for (let it of ite.list) {
  879. // data.push(it)
  880. // }
  881. // }
  882. // }
  883. // }、
  884. for (let item of this.companyValue) {
  885. for (let ite of this.dataList) {
  886. if (item == ite.name) {
  887. data.push({
  888. name: item,
  889. list: ite.list
  890. })
  891. }
  892. }
  893. }
  894. this.totalPrice = 0
  895. this.totalFreight = 0
  896. let num = 0
  897. for (let item of data) {
  898. let num1 = 0
  899. for (let items of item.list) {
  900. this.totalPrice += Number(items.price) * Number(items.goodsNum)
  901. num += Number(items.goodsNum)
  902. num1 += Number(items.goodsNum)
  903. }
  904. if (num1 == 1) {
  905. this.totalFreight += this.freight ? Number(this.freight) : 5
  906. this.totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
  907. }
  908. }
  909. /* if(num>1){
  910. this.totalFreight = 0
  911. } */
  912. this.totalFreight = this.totalFreight.toFixed(2)
  913. this.totalPrice = this.totalPrice.toFixed(2)
  914. this.selectedProduct = data
  915. },
  916. companyChange(n) {
  917. this.companyValue = n
  918. this.inventoryfun(this.dataList)
  919. }
  920. }
  921. }
  922. </script>
  923. <style lang="scss" scoped>
  924. .card {
  925. background: #FFFFFF;
  926. padding: 32rpx;
  927. margin: 20rpx 0;
  928. ::v-deep .u-checkbox__icon-wrap {
  929. border-color: #E75F37 !important;
  930. }
  931. ::v-deep .u-number-box {
  932. border: 2rpx #E1E1E1 solid;
  933. border-radius: 8rpx;
  934. }
  935. ::v-deep .u-number-box__minus {
  936. border-right: 2rpx #E1E1E1 solid;
  937. }
  938. ::v-deep .u-number-box__plus {
  939. border-left: 2rpx #E1E1E1 solid;
  940. }
  941. }
  942. .submitBar {
  943. position: fixed;
  944. bottom: 0;
  945. background-color: #fff;
  946. width: 100%;
  947. z-index: 10;
  948. .balance-row {
  949. display: flex;
  950. justify-content: space-between;
  951. align-items: flex-start; /* 改为flex-start使内容顶部对齐 */
  952. padding: 15rpx 0 20rpx 0;
  953. .balance-info {
  954. text-align: right;
  955. display: flex;
  956. flex-direction: column;
  957. }
  958. }
  959. .top-row {
  960. display: flex;
  961. justify-content: space-between;
  962. align-items: center;
  963. padding: 10rpx 0;
  964. .select-all {
  965. flex: 1;
  966. }
  967. .total-price {
  968. flex: 1;
  969. text-align: right;
  970. }
  971. }
  972. .left-btn {
  973. background-color: #FFEEE9;
  974. color: #E75F37;
  975. font-size: 26rpx;
  976. width: 160rpx;
  977. height: 65rpx;
  978. display: flex;
  979. justify-content: center;
  980. align-items: center;
  981. border-top-left-radius: 33rpx;
  982. border-bottom-left-radius: 33rpx;
  983. }
  984. .right-btn {
  985. background-color: #E75F37;
  986. color: #fff;
  987. font-size: 26rpx;
  988. width: 160rpx;
  989. height: 65rpx;
  990. display: flex;
  991. justify-content: center;
  992. align-items: center;
  993. border-top-right-radius: 33rpx;
  994. border-bottom-right-radius: 33rpx;
  995. }
  996. }
  997. /* .submitBar {
  998. position: fixed;
  999. bottom: 0;
  1000. background-color: #fff;
  1001. width: 100%;
  1002. z-index: 10;
  1003. ::v-deep .u-checkbox__icon-wrap {
  1004. border-color: #E75F37 !important;
  1005. }
  1006. .left-btn {
  1007. background-color: #FFEEE9;
  1008. color: #E75F37;
  1009. font-size: 26rpx;
  1010. width: 160rpx;
  1011. height: 65rpx;
  1012. display: flex;
  1013. justify-content: center;
  1014. align-items: center;
  1015. border-top-left-radius: 33rpx;
  1016. border-bottom-left-radius: 33rpx;
  1017. }
  1018. .right-btn {
  1019. background-color: #E75F37;
  1020. color: #fff;
  1021. font-size: 26rpx;
  1022. width: 160rpx;
  1023. height: 65rpx;
  1024. display: flex;
  1025. justify-content: center;
  1026. align-items: center;
  1027. border-top-right-radius: 33rpx;
  1028. border-bottom-right-radius: 33rpx;
  1029. }
  1030. }*/
  1031. </style>