take-order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="page safe-area-inset-bottom">
  3. <view class="card u-border-bottom ">
  4. <view class="center">
  5. <image style="width: 60rpx;height: 60rpx;border-radius: 12rpx;" :src="shop.cover" mode=""></image>
  6. <text class="margin-left-10 text-lg text-cut-1">{{shop.name}}</text>
  7. </view>
  8. <view class="center text-sm " style="font-weight: 400;width: 46%;justify-content: flex-end;">
  9. <view class="text-center" v-if="order.payStatus=='待付款'&& order.orderStatus!='取消付款'">
  10. <view class="center">
  11. <text class="text-gray text-sm">付款倒计时:</text>
  12. <u-count-down @end="timeup" bg-color="#e44c41" font-size="26" height="42" color="#ffffff"
  13. :show-hours="false" :show-days="false" :timestamp="expireTime"></u-count-down>
  14. </view>
  15. </view>
  16. <block v-else>
  17. <text class="cuIcon-time margin-right-10"></text>
  18. <text>{{order.createTime}}</text>
  19. </block>
  20. </view>
  21. </view>
  22. <view class="section">
  23. </view>
  24. <view class="card section" style="flex-direction: column;">
  25. <block v-if="stepIndex==-1">
  26. <view class="center flex-direction" style="padding: 50rpx;">
  27. <text class="cuIcon-roundclose text-red" style="font-size: 150rpx;"></text>
  28. <text class="text-gray margin-top-10 text-df">订单已取消</text>
  29. </view>
  30. </block>
  31. <block v-else>
  32. <view class="center text-bold margin-50" style="font-size: 66rpx;">
  33. <text>{{order.verifyNum}}</text>
  34. </view>
  35. <view class="cu-steps steps-arrow margin-bottom-50">
  36. <view class="cu-item" :class="index>stepIndex?'text-default':'text-base'"
  37. v-for="(item,index) in stepList" :key="index">
  38. <text style="font-size: 70rpx;margin-bottom: 20rpx;margin-right: 10rpx;"
  39. :class="'cuIcon-' + item.icon"></text>
  40. <text>{{item.name}}</text>
  41. </view>
  42. </view>
  43. <view class="center padding-30" style="color: #999;">
  44. <text>备注:{{order.extraInfo || '无备注'}}</text>
  45. </view>
  46. </block>
  47. </view>
  48. <view class="section"></view>
  49. <view class="padding-10 bg-white">
  50. <u-read-more ref="uReadMore" close-text="展开更多" show-height="300" color="#999">
  51. <view v-for="(item,index) in cart" :key="index" class="cart">
  52. <view class="flex" style="width: 70%;">
  53. <image :src="item.image" mode=""></image>
  54. <view class="item-content ">
  55. <text class="text-cut-1">{{item.name}}</text>
  56. <text class="text-cut-1">{{item.propertyStr ? item.propertyStr : item.name}}</text>
  57. </view>
  58. </view>
  59. <view class="item-data">
  60. <view class="">
  61. <text class="text-sm">x</text>
  62. <text class="text-lg" style="margin-left: 6rpx;">{{item.number}}</text>
  63. </view>
  64. <text class=" text-lg">{{item.realPrice / 100}}</text>
  65. </view>
  66. </view>
  67. </u-read-more>
  68. </view>
  69. <!-- 订单金额 -->
  70. <view class="">
  71. <view class="card text-df" v-if="$isNotEmpty(order.packingPrice)&&order.packingPrice != -1">
  72. <text class="text-gray">包装费</text>
  73. <text class="text-price">{{order.packingPrice / 100}}</text>
  74. </view>
  75. <view class="card text-df" v-if="$isNotEmpty(order.sendingPrice)&&order.sendingPrice != -1">
  76. <text class="text-gray">配送费</text>
  77. <text class="text-price">{{order.sendingPrice / 100}}</text>
  78. </view>
  79. <view class="card text-df ">
  80. <text class="text-gray">金额总计</text>
  81. <view class="">
  82. <text class="text-price">{{order.totalPrice / 100}}</text>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="section"></view>
  87. <view class="">
  88. <view class="card text-df">
  89. <text class="text-gray">取单号</text>
  90. <text class="">{{order.verifyNum}}</text>
  91. </view>
  92. <view class="card text-df" v-if="$isNotEmpty(order.seatNum) && order.seatNum !=-1">
  93. <text class="text-gray">座位号</text>
  94. <text class="">{{order.seatNum}}</text>
  95. </view>
  96. <view class="card text-df">
  97. <text class="text-gray">下单时间</text>
  98. <text class="">{{order.createTime}}</text>
  99. </view>
  100. <view class="card text-df" v-if="order.orderStatus != -1">
  101. <text class="text-gray">付款状态</text>
  102. <text class="">{{order.payStatus}}</text>
  103. </view>
  104. <view class="card text-df" v-if="$isNotEmpty(order.orderStatus)">
  105. <text class="text-gray">订单状态</text>
  106. <text class="">{{order.orderStatus}}</text>
  107. </view>
  108. <view class="card text-df">
  109. <text class="text-gray">订单号</text>
  110. <text class="">{{order.id}}</text>
  111. </view>
  112. </view>
  113. <view class="">
  114. <view class="card text-df">
  115. <text class="text-gray">下单手机号</text>
  116. <text class="">{{order.userPhone}}</text>
  117. </view>
  118. <view class="card text-df">
  119. <text class="text-gray">取餐方式</text>
  120. <text class="">{{order.takeType}}</text>
  121. </view>
  122. <view class="card text-df">
  123. <text class="text-gray">下单时间</text>
  124. <text class="">{{order.createTime}}</text>
  125. </view>
  126. <view class="card text-df">
  127. <text class="text-gray">取餐时间</text>
  128. <text class="">{{order.takeTime || '立即就餐'}}</text>
  129. </view>
  130. <view class="card text-df">
  131. <text class="text-gray">备注</text>
  132. <text class="">{{order.extraInfo || '无备注'}}</text>
  133. </view>
  134. </view>
  135. <view class="">
  136. <view class="" style="height: 140rpx;"></view>
  137. <view class="footer-fixed " :style="'margin-bottom:'+safeAreaBottom+'px'">
  138. <view class="navigation">
  139. <view class="left">
  140. <view class="item" @click="$util.callPhone(shop.personTel)">
  141. <u-icon name="server-fill" :size="40" :color="$u.color['contentColor']"></u-icon>
  142. <view class="text u-line-1">客服</view>
  143. </view>
  144. <view class="item" @click="continueOrdre">
  145. <u-icon name="home" :size="40" :color="$u.color['contentColor']"></u-icon>
  146. <view class="text u-line-1">店铺</view>
  147. </view>
  148. <view class="item car" @click="goMap">
  149. <u-icon name="map" :size="40" :color="$u.color['contentColor']"></u-icon>
  150. <view class="text u-line-1">导航</view>
  151. </view>
  152. </view>
  153. <view class="right">
  154. <view @click="doWxPay" v-if="order.payStatus=='待付款'&&order.orderStatus!='取消付款'"
  155. class="buy btn u-line-1">立即付款</view>
  156. <view @click="againOrder" v-else class="buy btn u-line-1">再来一单</view>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. <toast ref="toast" ></toast>
  162. </view>
  163. </template>
  164. <script>
  165. export default {
  166. data() {
  167. return {
  168. expireTime: '',
  169. id: '',
  170. order: {},
  171. shop: {},
  172. cart: [],
  173. //订单流程
  174. stepList: [{
  175. name: '待付款',
  176. icon: 'rechargefill'
  177. },
  178. {
  179. name: '已付款',
  180. icon: 'roundcheckfill'
  181. },
  182. {
  183. name: '制作中',
  184. icon: 'timefill'
  185. },
  186. {
  187. name: '已完成',
  188. icon: 'goodsfill'
  189. }
  190. ],
  191. };
  192. },
  193. onLoad(options) {
  194. this.id = options.id
  195. this.fetchDetail()
  196. },
  197. computed: {
  198. stepIndex: {
  199. get() {
  200. if (this.order.payStatus == '待付款') {
  201. return 0
  202. }
  203. if (this.order.orderStatus == '已完成') {
  204. return 3
  205. }
  206. if (this.order.orderStatus == '取消付款') {
  207. return -1
  208. } else {
  209. return 2
  210. }
  211. }
  212. }
  213. },
  214. methods: {
  215. async fetchDetail() {
  216. let params = {
  217. id: this.id
  218. }
  219. let res = await this.$api.order.detail(params)
  220. this.order = res.data || {}
  221. this.shop = this.order.shop || {}
  222. this.cart = JSON.parse(this.order.goodsPreview)
  223. if (this.order.orderStatus != '取消付款') {
  224. this.getExTimestamp()
  225. }
  226. },
  227. getExTimestamp() {
  228. let exTime = this.$dateTime.getTime(this.order.expireTime)
  229. let nowTime = this.$dateTime.getTime()
  230. this.expireTime = (exTime - nowTime) / 1000
  231. if (this.expireTime <= 0) {
  232. this.expireTime = 0.1
  233. }
  234. },
  235. timeup() {
  236. let order = this.$u.deepClone(this.order)
  237. order.payStatus = '取消付款'
  238. order.orderStatus = '取消付款'
  239. this.$api.goodsbills.submit(order).then(res => {
  240. if (res.success) {
  241. this.fetchDetail()
  242. }
  243. })
  244. },
  245. continueOrdre() {
  246. let params = {
  247. shopId: this.shop.id,
  248. }
  249. if (this.$isNotEmpty(this.order.seatNum)) {
  250. params.seatNum = this.order.seatNum
  251. }
  252. uni.redirectTo({
  253. url: "/pagesD/pages/menu/menu" + this.$u.queryParams(params)
  254. })
  255. },
  256. againOrder() {
  257. let cart = JSON.parse(this.order.goodsPreview)
  258. let cartKey = this.$global.cart_prefix + this.shop.id
  259. this.$cache.put(cartKey, cart)
  260. this.continueOrdre()
  261. },
  262. async doWxPay() {
  263. let obj = {
  264. orderType: this.$global.orderType.USER_PAY,
  265. orderId:this.order.billsId,
  266. payStatus: this.$global.payStatus.IS_WAIT
  267. }
  268. let res = await this.$api.pay.payOrder(obj)
  269. if (res.data.message!='成功') {
  270. this.$refs.toast.error(res.data.message)
  271. return
  272. }
  273. let prePayTn = JSON.parse(res.data.prePayTn)
  274. this.$mpi.requestPayment(prePayTn).then((res) => {
  275. this.$refs.toast.info('支付成功')
  276. this.fetchDetail()
  277. }).catch(err => {
  278. this.$refs.toast.error('支付失败')
  279. })
  280. },
  281. goMap() {
  282. let latitude = parseInt(this.shop.latitude)
  283. let longitude = parseInt(this.shop.longitude)
  284. let name = this.shop.name
  285. let address = this.shop.address
  286. uni.openLocation({
  287. latitude, //纬度
  288. longitude, //经度
  289. name,
  290. address,
  291. fail: (err) => {
  292. console.log(err);
  293. }
  294. });
  295. }
  296. }
  297. };
  298. </script>
  299. <style lang="scss" scoped>
  300. .page {
  301. margin: 20rpx;
  302. }
  303. .text-default {
  304. color: #ffbf91;
  305. }
  306. .btn-icon {
  307. background-color: rgba(255, 148, 71, .3);
  308. color: #FF9447;
  309. }
  310. .card {
  311. padding: 30rpx;
  312. background-color: #FFFFFF;
  313. border-bottom: 1rpx solid #f1f1f1;
  314. display: flex;
  315. justify-content: space-between;
  316. }
  317. .cart {
  318. border-bottom: 1rpx solid #f1f1f1;
  319. display: flex;
  320. background-color: #FFFFFF;
  321. padding: 15rpx 0;
  322. image {
  323. width: 100rpx;
  324. height: 100rpx;
  325. border-radius: 8rpx;
  326. }
  327. .item-content {
  328. width: calc(100% - 100rpx);
  329. margin-left: -40rpx;
  330. display: flex;
  331. flex-direction: column;
  332. justify-content: space-between;
  333. text:first-child {
  334. font-size: 30rpx;
  335. }
  336. text:last-child {
  337. font-size: 24rpx;
  338. color: #999;
  339. font-weight: 400;
  340. }
  341. }
  342. .item-data {
  343. display: flex;
  344. align-items: center;
  345. width: 30%;
  346. justify-content: space-between;
  347. margin-right: 20rpx;
  348. }
  349. }
  350. .cart:last-child {
  351. border: none;
  352. }
  353. .navigation {
  354. display: flex;
  355. justify-content: flex-end;
  356. margin-top: 100rpx;
  357. border: solid 2rpx #f2f2f2;
  358. background-color: #ffffff;
  359. padding: 16rpx 20rpx;
  360. .left {
  361. display: flex;
  362. font-size: 20rpx;
  363. .item {
  364. margin: 0 30rpx;
  365. &.car {
  366. text-align: center;
  367. position: relative;
  368. .car-num {
  369. position: absolute;
  370. top: -10rpx;
  371. right: -10rpx;
  372. }
  373. }
  374. }
  375. }
  376. .right {
  377. display: flex;
  378. font-size: 28rpx;
  379. align-items: center;
  380. margin-left: 20rpx;
  381. .btn {
  382. line-height: 66rpx;
  383. padding: 0 30rpx;
  384. border-radius: 36rpx;
  385. color: #ffffff;
  386. }
  387. .cart {
  388. background-color: #ed3f14;
  389. margin-right: 30rpx;
  390. }
  391. .buy {
  392. background-color: #ff7900;
  393. }
  394. }
  395. }
  396. </style>