obligation.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view>
  3. <view class="card" v-for="(item,index) in dataList" :key="index">
  4. <view style="font-size: 26rpx;color: #717171;margin-bottom: 28rpx;">
  5. {{ item.name }}
  6. </view>
  7. <view>
  8. <view style="display: flex;" v-for="(li,inde) in item.data.orderItemsList" :key="inde">
  9. <view style="display: flex;width: 100%;align-items: center;margin-bottom: 20rpx;">
  10. <image :src="li.url"
  11. style="width:120rpx;height: 120rpx;border-radius: 10rpx;border: 2rpx solid #EEEEEE;margin-right: 27rpx;"
  12. mode="scaleToFill">
  13. </image>
  14. <view style="width:477rpx;">
  15. <view
  16. style="display: flex;justify-content: space-between;align-items: center;font-size: 26rpx;color: #4E4E4E;font-weight: 500;">
  17. <u--text color="#4E4E4E" size="26rpx" :lines="1" :text="li.goodsName"></u--text>
  18. <view>
  19. ¥{{ li.price }}
  20. </view>
  21. </view>
  22. <view style="display: flex;justify-content:flex-end;margin-top: 20rpx;">
  23. <view style="font-size: 26rpx;color: #4D4D4D;">
  24. x{{ li.goodsNum }}
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view style="display: flex;justify-content: flex-end;">
  31. <view style="width: 136rpx;margin-right: 17rpx;">
  32. <u-button type="primary" text="取消订单" color="#E75F37" shape='circle' plain
  33. @click="deleteGoods(item.data.id)"></u-button>
  34. </view>
  35. <view style="width: 136rpx;">
  36. <u-button type="primary" text="去支付" color="#E75F37" shape='circle'
  37. @click="paySubmit(item.data,index,ind)"></u-button>
  38. </view>
  39. </view>
  40. <view style="width: 623rpx;height: 2rpx;background: #F1F1F1;margin: 48rpx 0 40rpx 0;">
  41. </view>
  42. <view style="font-size: 26rpx;color: #717171;">
  43. <view style="margin-bottom: 20rx;">
  44. 订单编号:
  45. <text style="color: #C4C4C4;">{{ item.data.ordNo }}</text>
  46. </view>
  47. <view style="margin-bottom: 20rx;">
  48. 支付方式:
  49. <text style="color: #C4C4C4;">
  50. {{ item.data.receivableType ? item.data.receivableType : '' }}
  51. </text>
  52. </view>
  53. <view>
  54. 下单时间:
  55. <text style="color: #C4C4C4;">{{ item.data.createTime }}</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <u-empty style="position: absolute;top: 45%;left: 50%;transform:translate(-50%,-50%)"
  61. v-if="dataList.length == 0 && !isLoading" mode="car" text="待付款为空"
  62. icon="http://cdn.uviewui.com/uview/empty/car.png"/>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. obligationList,
  68. update,
  69. getPaymentType,
  70. getPaymentByOrder,
  71. } from '@/api/tabBar/shoppingCart.js'
  72. import {closeOrder} from "@/api/tabBar/shoppingCart";
  73. export default {
  74. data() {
  75. return {
  76. dataList: [],
  77. payList: ['W01', 'A01', 'U01', 'S01'],
  78. totalPrice: 0.00,
  79. totalFreight: 0.00,
  80. isLoading: true,
  81. payType: null
  82. }
  83. },
  84. watch: {},
  85. onShow() {
  86. getPaymentType().then(res => {
  87. console.log(res.data, 111);
  88. this.payType = res.data
  89. })
  90. this.isLoading = true
  91. uni.showLoading({
  92. title: '加载中',
  93. mask: true
  94. });
  95. obligationList().then(res => {
  96. console.log(res);
  97. this.dataList = res.data
  98. this.isLoading = false // 添加这一行
  99. uni.hideLoading();
  100. }).catch(err => {
  101. uni.hideLoading();
  102. })
  103. },
  104. methods: {
  105. deleteGoods(orderId) {
  106. console.log(orderId);
  107. uni.showLoading({
  108. title: '加载中',
  109. mask: true
  110. });
  111. closeOrder({id: orderId}).then(res => {
  112. uni.hideLoading();
  113. console.info('res--------', res)
  114. uni.showToast({
  115. title: res.msg,
  116. icon: 'none',
  117. duration: 2500
  118. });
  119. setTimeout(() => {
  120. this.getList()
  121. }, 1000)
  122. }).catch(err => {
  123. uni.hideLoading();
  124. })
  125. },
  126. paySubmit(val, index, ind) {
  127. this.statistics(val, index, ind)
  128. },
  129. submit(itemData, index) {
  130. console.log('itemData-----', itemData)
  131. if (this.dataList[index].paySuccess == true) {
  132. uni.showToast({
  133. title: "当前订单已完成支付, 请勿重复支付",
  134. icon: 'none',
  135. duration: 2500
  136. });
  137. return
  138. }
  139. if (itemData == null || itemData == {}) {
  140. uni.showToast({
  141. title: "请先选择要支付的商品",
  142. icon: 'none'
  143. });
  144. return
  145. }
  146. if (!itemData.payType) {
  147. uni.showToast({
  148. title: "当前订单支付方式异常,请重新购买",
  149. icon: 'none',
  150. duration: 2500
  151. });
  152. return
  153. }
  154. if (itemData.payType && itemData.payType == 'W06') {
  155. console.log('---------------------------------')
  156. this.normalPayment(itemData, index)
  157. }
  158. },
  159. async normalPayment(itemData, index) {
  160. uni.showLoading({
  161. title: '加载中',
  162. mask: true
  163. });
  164. // 正常支付
  165. getPaymentByOrder({
  166. id: itemData.id
  167. }).then(res => {
  168. let generateOrderData = res.data
  169. if (!generateOrderData.reqsn) {
  170. uni.showToast({
  171. title: '当前订单号为空,请联系供应商!!!',
  172. icon: 'none',
  173. mask: true,
  174. duration: 2000
  175. });
  176. // 详情调用
  177. this.getList()
  178. return
  179. }
  180. wx.openEmbeddedMiniProgram({
  181. appId: 'wxef277996acc166c3',
  182. extraData: {
  183. cusid: generateOrderData.cusid,
  184. appid: generateOrderData.appid,
  185. orgid: generateOrderData.orgid,
  186. version: generateOrderData.version,
  187. trxamt: generateOrderData.trxamt,
  188. reqsn: generateOrderData.reqsn,
  189. notify_url: generateOrderData.notify_url,
  190. body: generateOrderData.body,
  191. remark: generateOrderData.remark,
  192. validtime: generateOrderData.validtime,
  193. limit_pay: "",
  194. randomstr: generateOrderData.randomstr,
  195. paytype: generateOrderData.paytype,
  196. signtype: generateOrderData.signtype,
  197. sign: generateOrderData.sign,
  198. },
  199. success: (a) => {
  200. this.dataList[index].paySuccess = true
  201. uni.hideLoading();
  202. },
  203. fail: (err) => {
  204. uni.hideLoading();
  205. }
  206. })
  207. }).catch(err => {
  208. uni.hideLoading();
  209. })
  210. },
  211. getList() {
  212. uni.showLoading({
  213. title: '加载中',
  214. mask: true
  215. });
  216. obligationList().then(res => {
  217. this.dataList = res.data
  218. uni.hideLoading();
  219. }).catch(err => {
  220. uni.hideLoading();
  221. })
  222. },
  223. statistics(orderData, index, ind) {
  224. orderData.payType = orderData.payType ? orderData.payType : this.payType
  225. this.totalPrice = 0
  226. this.totalFreight = 0
  227. for (let orderItem of orderData.orderItemsList) {
  228. this.totalPrice += Number(orderItem.price) * Number(orderItem.goodsNum)
  229. }
  230. console.log(orderData.goodsTotalNum);
  231. if (Number(orderData.goodsTotalNum) == 1) {
  232. this.totalFreight += 5
  233. }
  234. this.totalFreight = this.totalFreight.toFixed(2)
  235. this.totalPrice = this.totalPrice.toFixed(2)
  236. this.submit(orderData, index)
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. .card {
  243. padding: 54rpx 63rpx;
  244. background-color: #fff;
  245. margin-bottom: 20rpx;
  246. ::v-deep .u-button {
  247. height: 60rpx;
  248. }
  249. }
  250. </style>