orderPaid.vue 9.5 KB

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