shoppingCart.vue 31 KB

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