orderPaid.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="order-detail">
  3. <topNavBar title="订单详情" />
  4. <view class="order-state padding-sm dflex-b w-full">
  5. <view class="state-left">
  6. <view class="state-info">待支付 </view>
  7. <view class="order-code">剩余 09:59 逾期未支付将自动取消</view>
  8. </view>
  9. <!-- <uni-icons type="right" size="24" color="#FFF"></uni-icons> -->
  10. </view>
  11. <view class="gap"></view>
  12. <view class="padding-sm dflex-b bg-main" @click="show = true">
  13. <view class="dflex">
  14. <view class="w-full dflex-wrap-w send-label">
  15. 取餐时间
  16. </view>
  17. </view>
  18. <u-icon slot="icon" size="20" name="arrow-right" label="15:00" labelPos="left"></u-icon>
  19. <!-- <u-icon slot="icon" size="20" name="arrow-right" :label="goods.orderPickup.writeOffTime" labelPos="left"></u-icon> -->
  20. </view>
  21. <view class="gap"></view>
  22. <view class="padding-sm dflex-b bg-main">
  23. <view class="dflex">
  24. <view class="w-full dflex-wrap-w send-label">
  25. 取餐方式
  26. </view>
  27. </view>
  28. <view>
  29. <!-- 字段返回数据有问题 -->
  30. <radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">
  31. {{goods.pickupType.pickupType == '0' ? '打包带走' : '店内用餐'}}
  32. </radio>
  33. </view>
  34. </view>
  35. <view class="gap"></view>
  36. <view class="goods-order-list padding-lr-sm">
  37. <view class="shop dflex-b ">
  38. <view class="shop-check">
  39. <text class="send-label">{{goods.storeName}}</text>
  40. </view>
  41. <view class="total-goods">共计{{lists}}件商品</view>
  42. </view>
  43. <view class="goods-cart w-full">
  44. <view class="goods-cont padding-tb" v-for="(item, index) in goods.orderItemVoList" :key="index">
  45. <my-goods :item="item">
  46. <view class="good-num">×{{item.quantity}}</view>
  47. </my-goods>
  48. </view>
  49. </view>
  50. <!-- <view class="goods-cart" v-for="(item, index) in goods.itemList" :key="index">
  51. <view class="goods-cont dflex-b padding-tb-16">
  52. <view class="goods-cart-info dflex-b">
  53. <view class="pic"></view>
  54. <my-goods :item="item">
  55. <view class="good-num">×{{item.quantity}}</view>
  56. </my-goods>
  57. <view class="goods-cart-right">
  58. <view class="cart-title">{{item.skuName}}</view>
  59. <view class="order-spec">
  60. <text>500g</text>
  61. </view>
  62. <view class="cart-row-info dflex-s">
  63. <view class="cart-price">
  64. ¥<text>{{item.price}}</text>
  65. </view>
  66. <view class="goods-num">×{{item.quantity}}</view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="goods-cont dflex-b padding-tb-16">
  72. <view class="goods-cart-info dflex-b">
  73. <view class="pic"></view>
  74. <view class="goods-cart-right">
  75. <view class="cart-title">商品名称商品名称</view>
  76. <view class="order-spec">
  77. <text>500g</text>
  78. </view>
  79. <view class="cart-row-info dflex-s">
  80. <view class="cart-price">
  81. ¥<text>12.30</text>
  82. </view>
  83. <view class="goods-num">×1</view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view> -->
  89. </view>
  90. <view class="gap"></view>
  91. <!-- 金额明细 -->
  92. <view class="bg-main">
  93. <view class="dflex-b padding-lr padding-tb-sm">
  94. <view class="flex1 send-label">总金额</view>
  95. <view class="price">{{goods.totalAmount}}</view>
  96. </view>
  97. </view>
  98. <view class="gap"></view>
  99. <view class="bar-space"></view>
  100. <view class="cart-bottom padding-sm dflex-b">
  101. <view class="go-cart dflex-c" @click="toDelete()">取消订单</view>
  102. <view class="go-buy dflex-c background-gradient" @click="toPay()">去支付</view>
  103. </view>
  104. <u-toast ref="uToast"></u-toast>
  105. </view>
  106. </template>
  107. <script>
  108. export default {
  109. data() {
  110. return {
  111. goods: {},
  112. lists: 0
  113. }
  114. },
  115. onLoad(e) {
  116. var dataString = decodeURIComponent(e.data)
  117. var data = JSON.parse(dataString);
  118. console.log('data', data)
  119. this.goods = data
  120. this.lists = this.goods.orderItemVoList.length
  121. this.goods.orderItemVoList.forEach(item => {
  122. item.imgUrl = item.picUrl
  123. })
  124. console.log('this.lists', this.lists)
  125. // this.fatchDate(e)
  126. },
  127. methods: {
  128. async fatchDate(e) {
  129. console.log('e', e)
  130. const result = await this.$request('get', `/order/tradeOrder/queryTradeOrder/${e.id}`,
  131. true)
  132. if (result) {
  133. console.log('result', result.data)
  134. this.goods = result.data
  135. this.lists = this.goods.itemList.length
  136. this.goods.itemList.forEach(item => {
  137. item.imgUrl = item.picUrl
  138. })
  139. console.log('this.goods', this.goods)
  140. console.log('this.goods.itemList', this.goods.itemList)
  141. }
  142. },
  143. uuid() {
  144. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  145. var r = Math.random() * 16 | 0,
  146. v = c == 'x' ? r : (r & 0x3 | 0x8);
  147. return v.toString(16);
  148. });
  149. },
  150. toDelete() {
  151. this.$refs.uToast.show({
  152. type: 'default',
  153. title: '默认主题',
  154. message: "演示阶段暂时不能取消",
  155. position: 'center'
  156. })
  157. },
  158. toPay() {
  159. // 显示提示
  160. this.$refs.uToast.show({
  161. type: 'default',
  162. title: '默认主题',
  163. message: "演示阶段暂时不能支付",
  164. position: 'center'
  165. })
  166. // uni.showToast({
  167. // title: '演示阶段暂时不能支付',
  168. // icon: 'error',
  169. // duration: 1000
  170. // });
  171. // const params = {
  172. // orderId: this.goods.orderId,
  173. // amount: this.goods.payment,
  174. // }
  175. // this.$request('post', `/order/orderPay/addOrderPay`, params, true).then(res => {
  176. // this._toPay()
  177. // })
  178. },
  179. async _toPay() {
  180. console.log('this.uuid()', this.uuid())
  181. const openId = uni.getStorageSync('openId');
  182. const token = uni.getStorageSync('token');
  183. if (!token) {
  184. await this.autoLogin()
  185. }
  186. const that = this;
  187. uni.request({
  188. url: 'http://36.137.224.81:8030/weChatPay/payment/miniPay',
  189. header: {
  190. // "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", //
  191. "Content-Type": "application/json;charset=UTF-8", //
  192. 'Authorization': 'Bearer ' + token,
  193. },
  194. method: 'post',
  195. data: {
  196. tenantId: '000000',
  197. outTradeNo: this.uuid(),
  198. openId: openId,
  199. total: Math.round(this.goods.payment * 10), //以分为单位
  200. profitSharing: false // 是否分销
  201. },
  202. success: res => {
  203. console.log('预支付成功')
  204. that.data = res.data;
  205. wx.requestPayment({
  206. "timeStamp": res.data.timeStamp,
  207. "nonceStr": res.data.nonceStr,
  208. "package": res.data.packageValue,
  209. "signType": "RSA",
  210. "paySign": res.data.paySign,
  211. "success": function(res) {
  212. console.log('调用支付接口成功', res)
  213. },
  214. "fail": function(res) {
  215. console.log('调用支付接口fail', res)
  216. },
  217. "complete": function(res) {
  218. console.log('调用支付接口完成', res)
  219. }
  220. })
  221. },
  222. fail: err => {
  223. uni.hideLoading()
  224. }
  225. })
  226. // const params = {
  227. // tenantId: '000000',
  228. // outTradeNo: this.uuid(),
  229. // openId: openId,
  230. // total: Math.round(this.goods.payment * 10), //以分为单位
  231. // profitSharing: false // 是否分销
  232. // }
  233. // console.log('params', params)
  234. // this.$request('post', `/weChatPay/payment/miniPay`, params, true).then(res => {
  235. // // 请求成功
  236. // console.log('response', res)
  237. // console.log('预支付成功')
  238. // that.data = res.data;
  239. // wx.requestPayment({
  240. // "timeStamp": res.data.timeStamp,
  241. // "nonceStr": res.data.nonceStr,
  242. // "package": res.data.packageValue,
  243. // "signType": "RSA",
  244. // "paySign": res.data.paySign,
  245. // "success": function(res) {
  246. // console.log('调用支付接口成功', res)
  247. // },
  248. // "fail": function(res) {
  249. // console.log('调用支付接口fail', res)
  250. // },
  251. // "complete": function(res) {
  252. // console.log('调用支付接口完成', res)
  253. // }
  254. // })
  255. // }).catch(error => {
  256. // // 请求失败
  257. // uni.hideLoading()
  258. // console.error('请求失败:', error);
  259. // })
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. .order-state {
  266. background-color: #F96C22;
  267. box-sizing: border-box;
  268. color: #FFF;
  269. .state-info {
  270. font-size: 18px;
  271. padding-bottom: 4px;
  272. }
  273. .order-code {
  274. font-size: 12px;
  275. }
  276. }
  277. .addr-label {
  278. padding: 6upx 0;
  279. border-radius: 3px;
  280. background-color: #F6390D;
  281. color: #fff;
  282. width: 120upx;
  283. text-align: center;
  284. flex-shrink: 0;
  285. margin-right: 14upx;
  286. }
  287. .order-spec {
  288. padding-bottom: 10upx;
  289. }
  290. .shop {
  291. padding-top: 20upx;
  292. }
  293. .goods-num {
  294. font-size: 16px;
  295. padding-left: 20upx;
  296. }
  297. .sub-coupon {
  298. padding-top: 20upx;
  299. padding-bottom: 0;
  300. color: #000;
  301. .coupon-name {
  302. font-weight: normal;
  303. }
  304. .mj-tag {
  305. background-color: #F6390D;
  306. >text {
  307. color: #FFF;
  308. }
  309. }
  310. }
  311. .total-goods {
  312. font-size: 12px;
  313. color: #999;
  314. }
  315. .submit-bar {
  316. height: 100upx;
  317. width: 100%;
  318. background-color: #FFF;
  319. position: fixed;
  320. left: 0;
  321. bottom: 0;
  322. .submit-total {
  323. font-size: 16px;
  324. font-weight: 700;
  325. color: #F6390D;
  326. }
  327. .submit-btn {
  328. background-image: $base-bg-gradient-color;
  329. height: 70upx;
  330. width: 200upx;
  331. color: #FFF;
  332. font-size: 14px;
  333. font-weight: 700;
  334. border-radius: 35upx;
  335. }
  336. }
  337. .order-btn {
  338. height: 76upx;
  339. border-radius: 38px;
  340. background-image: $base-bg-gradient-color;
  341. text-align: center;
  342. line-height: 76upx;
  343. color: #FFF;
  344. font-size: 14px;
  345. width: 90%;
  346. position: fixed;
  347. left: 5%;
  348. bottom: 30upx;
  349. z-index: 99;
  350. }
  351. .order-info {
  352. background-color: #FFF;
  353. box-sizing: border-box;
  354. }
  355. .row-cell {
  356. padding-bottom: 20upx;
  357. .cell-right {
  358. font-size: 12px;
  359. color: #999;
  360. }
  361. }
  362. .row-cell:last-child {
  363. padding-bottom: 0;
  364. }
  365. .pic {
  366. margin-right: 20upx;
  367. height: 160rpx;
  368. width: 160rpx;
  369. background-color: #EEE;
  370. }
  371. .send-label {
  372. font-size: 14px;
  373. font-weight: 700;
  374. }
  375. .cart-bottom {
  376. width: 100%;
  377. position: fixed;
  378. left: 0;
  379. bottom: 0;
  380. height: 130rpx;
  381. box-sizing: border-box;
  382. background-color: #FFF;
  383. z-index: 10;
  384. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.15);
  385. .go-cart {
  386. height: 80%;
  387. box-sizing: border-box;
  388. border: solid 1px #FF0000;
  389. font-size: 14px;
  390. color: #FF0000;
  391. border-radius: 50upx;
  392. margin: 0 10px;
  393. width: 45%;
  394. }
  395. .go-buy {
  396. height: 80%;
  397. width: 45%;
  398. background-color: #FF0000;
  399. color: #FFF;
  400. border-radius: 50upx;
  401. font-size: 14px;
  402. }
  403. }
  404. .good-num {
  405. font-size: 12px;
  406. padding-top: 65rpx;
  407. }
  408. .goods-cont {
  409. width: 100%;
  410. box-sizing: border-box;
  411. }
  412. </style>