obligation.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 v-if="item.data.freight > 0">
  54. 运费:
  55. <text style="color: #C4C4C4;">{{ item.data.freight }}</text>
  56. </view>
  57. <view>
  58. 下单时间:
  59. <text style="color: #C4C4C4;">{{ item.data.createTime }}</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <u-empty style="position: absolute;top: 45%;left: 50%;transform:translate(-50%,-50%)"
  65. v-if="dataList.length == 0 && !isLoading" mode="car" text="待付款为空"
  66. icon="http://cdn.uviewui.com/uview/empty/car.png"/>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. obligationList,
  72. update,
  73. getPaymentType,
  74. getPaymentByOrder,
  75. } from '@/api/tabBar/shoppingCart.js'
  76. import {closeOrder} from "@/api/tabBar/shoppingCart";
  77. export default {
  78. data() {
  79. return {
  80. dataList: [],
  81. payList: ['W01', 'A01', 'U01', 'S01'],
  82. totalPrice: 0.00,
  83. totalFreight: 0.00,
  84. isLoading: true,
  85. payType: null
  86. }
  87. },
  88. watch: {},
  89. onShow() {
  90. getPaymentType().then(res => {
  91. console.log(res.data, 111);
  92. this.payType = res.data
  93. })
  94. this.isLoading = true
  95. uni.showLoading({
  96. title: '加载中',
  97. mask: true
  98. });
  99. obligationList().then(res => {
  100. console.log(res);
  101. this.dataList = res.data
  102. this.isLoading = false // 添加这一行
  103. uni.hideLoading();
  104. }).catch(err => {
  105. uni.hideLoading();
  106. })
  107. },
  108. methods: {
  109. deleteGoods(orderId) {
  110. console.log(orderId);
  111. uni.showLoading({
  112. title: '加载中',
  113. mask: true
  114. });
  115. closeOrder({id: orderId}).then(res => {
  116. uni.hideLoading();
  117. console.info('res--------', res)
  118. uni.showToast({
  119. title: res.msg,
  120. icon: 'none',
  121. duration: 2500
  122. });
  123. setTimeout(() => {
  124. this.getList()
  125. }, 1000)
  126. }).catch(err => {
  127. uni.hideLoading();
  128. })
  129. },
  130. paySubmit(val, index, ind) {
  131. this.statistics(val, index, ind)
  132. },
  133. submit(itemData, index) {
  134. console.log('itemData-----', itemData)
  135. if (this.dataList[index].paySuccess == true) {
  136. uni.showToast({
  137. title: "当前订单已完成支付, 请勿重复支付",
  138. icon: 'none',
  139. duration: 2500
  140. });
  141. return
  142. }
  143. if (itemData == null || itemData == {}) {
  144. uni.showToast({
  145. title: "请先选择要支付的商品",
  146. icon: 'none'
  147. });
  148. return
  149. }
  150. if (!itemData.payType) {
  151. uni.showToast({
  152. title: "当前订单支付方式异常,请重新购买",
  153. icon: 'none',
  154. duration: 2500
  155. });
  156. return
  157. }
  158. if (itemData.payType && itemData.payType == 'W06') {
  159. console.log('---------------------------------')
  160. this.normalPayment(itemData, index)
  161. }
  162. },
  163. async normalPayment(itemData, index) {
  164. uni.showLoading({
  165. title: '加载中',
  166. mask: true
  167. });
  168. // 正常支付
  169. getPaymentByOrder({
  170. id: itemData.id
  171. }).then(res => {
  172. let generateOrderData = res.data
  173. if (!generateOrderData.reqsn) {
  174. uni.showToast({
  175. title: '当前订单号为空,请联系供应商!!!',
  176. icon: 'none',
  177. mask: true,
  178. duration: 2000
  179. });
  180. // 详情调用
  181. this.getList()
  182. return
  183. }
  184. wx.openEmbeddedMiniProgram({
  185. appId: 'wxef277996acc166c3',
  186. extraData: {
  187. cusid: generateOrderData.cusid,
  188. appid: generateOrderData.appid,
  189. orgid: generateOrderData.orgid,
  190. version: generateOrderData.version,
  191. trxamt: generateOrderData.trxamt,
  192. reqsn: generateOrderData.reqsn,
  193. notify_url: generateOrderData.notify_url,
  194. body: generateOrderData.body,
  195. remark: generateOrderData.remark,
  196. validtime: generateOrderData.validtime,
  197. limit_pay: "",
  198. randomstr: generateOrderData.randomstr,
  199. paytype: generateOrderData.paytype,
  200. signtype: generateOrderData.signtype,
  201. sign: generateOrderData.sign,
  202. },
  203. success: (a) => {
  204. this.dataList[index].paySuccess = true
  205. uni.hideLoading();
  206. },
  207. fail: (err) => {
  208. uni.hideLoading();
  209. }
  210. })
  211. }).catch(err => {
  212. uni.hideLoading();
  213. })
  214. },
  215. getList() {
  216. uni.showLoading({
  217. title: '加载中',
  218. mask: true
  219. });
  220. obligationList().then(res => {
  221. this.dataList = res.data
  222. uni.hideLoading();
  223. }).catch(err => {
  224. uni.hideLoading();
  225. })
  226. },
  227. statistics(orderData, index, ind) {
  228. orderData.payType = orderData.payType ? orderData.payType : this.payType
  229. this.totalPrice = 0
  230. this.totalFreight = 0
  231. for (let orderItem of orderData.orderItemsList) {
  232. this.totalPrice += Number(orderItem.price) * Number(orderItem.goodsNum)
  233. }
  234. console.log(orderData.goodsTotalNum);
  235. if (Number(orderData.goodsTotalNum) == 1) {
  236. this.totalFreight += 5
  237. }
  238. this.totalFreight = this.totalFreight.toFixed(2)
  239. this.totalPrice = this.totalPrice.toFixed(2)
  240. this.submit(orderData, index)
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .card {
  247. padding: 54rpx 63rpx;
  248. background-color: #fff;
  249. margin-bottom: 20rpx;
  250. ::v-deep .u-button {
  251. height: 60rpx;
  252. }
  253. }
  254. </style>