obligation.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <view>
  3. <view class="card" v-for="(item,index) in dataList" :key="index">
  4. <view v-for="(ite,ind) in item.list" :key="ind">
  5. <view style="font-size: 26rpx;color: #717171;margin-bottom: 28rpx;">
  6. {{item.name}}
  7. </view>
  8. <view>
  9. <view style="display: flex;" v-for="(li,inde) in ite.orderItemsList" :key="inde">
  10. <view style="display: flex;width: 100%;align-items: center;margin-bottom: 20rpx;">
  11. <image :src="li.url"
  12. style="width:120rpx;height: 120rpx;border-radius: 10rpx;border: 2rpx solid #EEEEEE;margin-right: 27rpx;"
  13. mode="scaleToFill">
  14. </image>
  15. <view style="width:477rpx;">
  16. <view
  17. style="display: flex;justify-content: space-between;align-items: center;font-size: 26rpx;color: #4E4E4E;font-weight: 500;">
  18. <u--text color="#4E4E4E" size="26rpx" :lines="1" :text="li.goodsName"></u--text>
  19. <view>
  20. ¥{{li.price}}
  21. </view>
  22. </view>
  23. <view style="display: flex;justify-content:flex-end;margin-top: 20rpx;">
  24. <view style="font-size: 26rpx;color: #4D4D4D;">
  25. x{{li.goodsNum}}
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view style="display: flex;justify-content: flex-end;">
  33. <view style="width: 136rpx;margin-right: 17rpx;">
  34. <u-button type="primary" text="取消订单" color="#E75F37" shape='circle' plain
  35. @click="deleteGoods(ite.id)"></u-button>
  36. </view>
  37. <view style="width: 136rpx;">
  38. <u-button type="primary" text="去支付" color="#E75F37" shape='circle'
  39. @click="paySubmit(item,index,ind)"></u-button>
  40. </view>
  41. </view>
  42. <view style="width: 623rpx;height: 2rpx;background: #F1F1F1;margin: 48rpx 0 40rpx 0;">
  43. </view>
  44. <view style="font-size: 26rpx;color: #717171;">
  45. <view style="margin-bottom: 20rx;">
  46. 订单编号:<text style="color: #C4C4C4;">{{ite.ordNo}}</text>
  47. </view>
  48. <view style="margin-bottom: 20rx;">
  49. 支付方式:<text
  50. style="color: #C4C4C4;">{{ite.payType && ite.payType.indexOf('01') != -1?'扫码支付':'微信支付'}}</text>
  51. </view>
  52. <view>
  53. 下单时间:<text style="color: #C4C4C4;">{{ite.createTime}}</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <u-empty style="position: absolute;top: 45%;left: 50%;transform:translate(-50%,-50%)"
  59. v-if="dataList.length == 0 && !isLoading" mode="car" text="待付款为空"
  60. icon="http://cdn.uviewui.com/uview/empty/car.png" />
  61. <u-popup :show="qrcodeshow" mode="center" :closeable="true" @close="qrcodeclose">
  62. <view style="padding: 20rpx;">
  63. <view style="font-size: 26rpx;">截屏二维码支付</view>
  64. <view>
  65. <uqrcode ref="uqrcode" canvas-id="qrcode" size="600" sizeUnit="rpx" :value="qrcodeurl"
  66. :options="{ margin: 5 }"></uqrcode>
  67. <!-- options 配置项 https://uqrcode.cn/doc/document/native.html#%E5%AE%9E%E4%BE%8B%E6%96%B9%E6%B3%95 -->
  68. </view>
  69. <view>
  70. <!-- {{qrcodeData.contacts}} -->
  71. <view style="font-size: 34rpx;font-weight: 500;">{{qrcodeData.salesCompanyName}}</view>
  72. <view style="color: #9a9a9a;font-size: 26rpx;">
  73. <text>金额:</text>
  74. <text style="color: #E75F37;font-size: 30rpx;">¥{{qrcodeData.salesAmount}}</text>
  75. </view>
  76. <view style="color: #9a9a9a;font-size: 26rpx;">二维码有效期: {{qrcodeData.businesDate}}</view>
  77. </view>
  78. </view>
  79. </u-popup>
  80. </view>
  81. </template>
  82. <script>
  83. import {
  84. obligationList,
  85. generateOrder,
  86. payPrepay,
  87. shoppingCartUpdate,
  88. getCorpsAddr,
  89. update,
  90. paramserviceDetail,
  91. isProcurement,
  92. getPaymentType
  93. } from '@/api/tabBar/shoppingCart.js'
  94. import {
  95. registerRuntimeCompiler
  96. } from "vue"
  97. import {
  98. logo
  99. } from '../../../common/setting'
  100. import {
  101. appDetail
  102. } from '@/api/views/salesSlip/index.js'
  103. import {
  104. dateFormat
  105. } from '@/common/dateFormat.js'
  106. export default {
  107. data() {
  108. return {
  109. qrcodeshow: false, // 二维码弹窗
  110. qrcodeData: [], // 二维码数据
  111. qrcodeurl: '', // 二维码参数
  112. editDel: false,
  113. radiovalue: [],
  114. companyValue: [],
  115. dataList: [],
  116. companyValueLength: 0,
  117. selectedProduct: [],
  118. totalPrice: 0.00,
  119. totalFreight: 0.00,
  120. addres: {},
  121. isLoading: true,
  122. payType:null
  123. }
  124. },
  125. watch: {
  126. companyValue() {
  127. if (this.companyValue.length != 0 || this.companyValueLength != 0) {
  128. if (this.companyValue.length == this.companyValueLength) {
  129. this.radiovalue = ["全选"]
  130. } else {
  131. this.radiovalue = []
  132. }
  133. }
  134. // if (this.companyValue.length > 0) {
  135. // console.log(21321324);
  136. // // if (this.companyValue.length == this.companyValueLength) {
  137. // // this.radiovalue = ["全选"]
  138. // // } else {
  139. // // this.radiovalue = []
  140. // // }
  141. // }
  142. // this.statistics()
  143. }
  144. },
  145. onLoad() {
  146. console.log(Date.parse('2023-11-22 00:00:00') + 60 * 60 * 1000);
  147. console.log(dateFormat(new Date(Date.parse('2023-11-22 00:00:00') + 60 * 60 * 1000)), 155);
  148. },
  149. onShow() {
  150. this.editDel = false
  151. this.companyValue = []
  152. getPaymentType().then(res => {
  153. console.log(res.data,111);
  154. this.payType=res.data
  155. })
  156. this.isLoading = true
  157. uni.showLoading({
  158. title: '加载中',
  159. mask: true
  160. });
  161. obligationList().then(res => {
  162. console.log(res);
  163. this.dataList = res.data
  164. this.companyValueLength = this.dataList.length
  165. this.isLoading = false // 添加这一行
  166. uni.hideLoading();
  167. }).catch(err => {
  168. uni.hideLoading();
  169. })
  170. getCorpsAddr().then(res => {
  171. this.addres = res.data
  172. })
  173. },
  174. methods: {
  175. // 弹窗关闭
  176. qrcodeclose() {
  177. this.qrcodeshow = false
  178. },
  179. deleteGoods(val) {
  180. console.log(val);
  181. uni.showLoading({
  182. title: '加载中',
  183. mask: true
  184. });
  185. update(val).then(res => {
  186. uni.showToast({
  187. title: "删除成功",
  188. icon: 'none'
  189. });
  190. uni.showLoading({
  191. title: '加载中',
  192. mask: true
  193. });
  194. this.editDel = false
  195. this.companyValue = []
  196. obligationList().then(res => {
  197. this.dataList = res.data
  198. this.companyValueLength = this.dataList.length
  199. uni.hideLoading();
  200. }).catch(err => {
  201. uni.hideLoading();
  202. })
  203. }).catch(err => {
  204. uni.hideLoading();
  205. })
  206. },
  207. deleteShopping() {
  208. if (this.selectedProduct.length == 0) {
  209. uni.showToast({
  210. title: "请先选择要支付的商品",
  211. icon: 'none'
  212. });
  213. return
  214. }
  215. let data = []
  216. for (let item of this.companyValue) {
  217. for (let ite of this.dataList) {
  218. if (item == ite.name) {
  219. for (let it of ite.list) {
  220. data.push(it.id)
  221. }
  222. }
  223. }
  224. };
  225. console.log(data.join(","));
  226. uni.showLoading({
  227. title: '加载中',
  228. mask: true
  229. });
  230. update(data.join(",")).then(res => {
  231. uni.showToast({
  232. title: "删除成功",
  233. icon: 'none'
  234. });
  235. uni.hideLoading();
  236. uni.showLoading({
  237. title: '加载中',
  238. mask: true
  239. });
  240. this.editDel = false
  241. this.companyValue = []
  242. obligationList().then(res => {
  243. this.dataList = res.data
  244. this.companyValueLength = this.dataList.length
  245. uni.hideLoading();
  246. }).catch(err => {
  247. uni.hideLoading();
  248. })
  249. }).catch(err => {
  250. uni.hideLoading();
  251. })
  252. },
  253. paySubmit(val, index, ind) {
  254. this.statistics(val, index, ind)
  255. },
  256. submit(payType) {
  257. console.log(this.selectedProduct)
  258. if (this.selectedProduct.length == 0) {
  259. uni.showToast({
  260. title: "请先选择要支付的商品",
  261. icon: 'none'
  262. });
  263. return
  264. }
  265. for (let item of this.selectedProduct) {
  266. if (!item.payType) return uni.showToast({
  267. title: "当前订单支付方式异常,请重新购买",
  268. icon: 'none',
  269. duration: 2500
  270. });
  271. if (item.payType && item.payType == 'W06') {
  272. // 微信支付
  273. } else {
  274. // 扫码支付
  275. let i = 0
  276. let j = 0
  277. console.log(this.selectedProduct)
  278. this.selectedProduct.forEach((item, index) => {
  279. console.log(item.payType.indexOf('01'))
  280. if (item.payType && item.payType.indexOf('01') != -1) {
  281. i++
  282. } else {
  283. j++
  284. }
  285. })
  286. if (j != 0) {
  287. uni.showToast({
  288. title: "请选择相同的支付方式",
  289. icon: 'none'
  290. });
  291. return
  292. }
  293. if (i > 1) {
  294. uni.showToast({
  295. title: "扫码支付只能选择一个",
  296. icon: 'none'
  297. });
  298. return
  299. }
  300. }
  301. }
  302. if (this.companyValue.length > 0) {
  303. let data = []
  304. for (let item of this.companyValue) {
  305. for (let ite of this.dataList) {
  306. if (item == ite.name) {
  307. data.push({
  308. name: item,
  309. })
  310. }
  311. }
  312. }
  313. console.log('data', data);
  314. uni.showLoading({
  315. title: '加载中',
  316. mask: true
  317. });
  318. payPrepay({
  319. srcOrderNo: data[0].name
  320. }).then(res => {
  321. let generateOrderData = res.data
  322. paramserviceDetail({
  323. paramKey: 'cashier.payment'
  324. }).then(res => {
  325. let paramservice = res.data
  326. // 判断是调支付台的接口还是微信支付的接口
  327. if (paramservice && paramservice.paramValue == '1') {
  328. wx.openEmbeddedMiniProgram({
  329. appId: 'wxef277996acc166c3',
  330. extraData: {
  331. cusid: generateOrderData.cusid,
  332. appid: generateOrderData.appid,
  333. orgid: generateOrderData.orgid,
  334. version: generateOrderData.version,
  335. trxamt: generateOrderData.trxamt,
  336. reqsn: generateOrderData.reqsn,
  337. notify_url: generateOrderData.notify_url,
  338. body: generateOrderData.body,
  339. remark: generateOrderData.remark,
  340. validtime: generateOrderData.validtime,
  341. limit_pay: generateOrderData.limit_pay,
  342. randomstr: generateOrderData.randomstr,
  343. paytype: generateOrderData.paytype,
  344. signtype: generateOrderData.signtype,
  345. sign: generateOrderData.sign,
  346. },
  347. success: (a) => {
  348. uni.hideLoading();
  349. },
  350. fail: (err) => {
  351. uni.hideLoading();
  352. }
  353. })
  354. } else {
  355. if (this.selectedProduct[0].payType &&
  356. (this.selectedProduct[0].payType == 'W01' || this.selectedProduct[0]
  357. .payType == 'U01' || this.selectedProduct[0].payType == 'A01' ||
  358. this.selectedProduct[0].payType == 'S01')) {
  359. this.qrcodeurl = this.selectedProduct[0].payUrl
  360. appDetail({
  361. id: this.selectedProduct[0].id
  362. }).then(res => {
  363. uni.hideLoading();
  364. this.qrcodeshow = true
  365. this.qrcodeData = res.data
  366. // 往后延长一小时
  367. this.qrcodeData.businesDate = dateFormat(new Date(Date
  368. .parse(this.qrcodeData.businesDate) + 60 * 60 *
  369. 1000))
  370. })
  371. } else {
  372. uni.requestPayment({
  373. provider: "wxpay",
  374. appId: generateOrderData.appId,
  375. timeStamp: generateOrderData.timeStamp,
  376. nonceStr: generateOrderData.nonceStr,
  377. package: generateOrderData.package,
  378. signType: generateOrderData.signType,
  379. paySign: generateOrderData.paySign,
  380. success(res) {
  381. uni.showToast({
  382. title: '支付成功',
  383. mask: true,
  384. duration: 2000
  385. });
  386. setTimeout(function() {
  387. uni.hideLoading();
  388. // this_.refresh(res.data.data.id)
  389. }, 1000);
  390. },
  391. fail(e) {
  392. console.log(e);
  393. uni.showToast({
  394. title: "支付失败",
  395. icon: 'none',
  396. mask: true
  397. });
  398. setTimeout(function() {
  399. uni.hideLoading();
  400. // this_.refresh(res.data.id)
  401. }, 1000);
  402. }
  403. })
  404. }
  405. }
  406. })
  407. // uni.showToast({
  408. // title: "提交成功",
  409. // icon: 'none'
  410. // });
  411. // uni.hideLoading();
  412. // uni.showLoading({
  413. // title: '加载中',
  414. // mask: true
  415. // });
  416. // this.editDel = false
  417. // this.companyValue = []
  418. // shoppingCartList().then(res => {
  419. // this.dataList = res.data
  420. // this.companyValueLength = this.dataList.length
  421. // uni.hideLoading();
  422. // }).catch(err => {
  423. // uni.hideLoading();
  424. // })
  425. }).catch(err => {
  426. uni.hideLoading();
  427. })
  428. }
  429. },
  430. radioGroupChange(e) {
  431. this.radiovalue = e
  432. if (e.length == 0) {
  433. this.companyValue = []
  434. } else {
  435. for (let li of this.dataList) {
  436. if (!this.companyValue.includes(li.name)) {
  437. this.companyValue.push(li.name)
  438. }
  439. }
  440. }
  441. // this.statistics()
  442. },
  443. statistics(val, index, ind) {
  444. let data = []
  445. for (let it of val.list) {
  446. if (it.payType) {
  447. data.push(it)
  448. }else{
  449. it.payType=this.payType
  450. data.push(it)
  451. }
  452. }
  453. this.totalPrice = 0
  454. this.totalFreight = 0
  455. for (let item of data) {
  456. for (let orderItem of item.orderItemsList) {
  457. this.totalPrice += Number(orderItem.price) * Number(orderItem.goodsNum)
  458. console.log(orderItem.goodsNum);
  459. if (Number(orderItem.goodsNum) == 1) {
  460. this.totalFreight += 5
  461. }
  462. }
  463. }
  464. this.totalFreight = this.totalFreight.toFixed(2)
  465. this.totalPrice = this.totalPrice.toFixed(2)
  466. this.selectedProduct = data
  467. this.submit()
  468. },
  469. companyChange(n) {
  470. if (n == 0) {
  471. this.dataList.forEach((e => {
  472. e.disabled = false
  473. }))
  474. } else {
  475. this.dataList.forEach((e => {
  476. if (n[0] != e.name) {
  477. e.disabled = true
  478. }
  479. }))
  480. }
  481. this.companyValue = n
  482. }
  483. }
  484. }
  485. </script>
  486. <style lang="scss" scoped>
  487. .card {
  488. padding: 54rpx 63rpx;
  489. background-color: #fff;
  490. margin-bottom: 20rpx;
  491. ::v-deep .u-button {
  492. height: 60rpx;
  493. }
  494. }
  495. </style>