敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

551 lines
14 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="订单详情 " leftClick @leftClick="navigateBack" bgColor="#019245" color="#fff" />
  5. <!-- 店铺信息 -->
  6. <view class="shop-info">
  7. <view class="shop-header">
  8. <image class="shop-logo" :src="teamLeader.spotImage" mode="aspectFill"></image>
  9. <view class="shop-name-container">
  10. <text class="shop-name"> {{ teamLeader.spotName }} </text>
  11. <view class="shop-address">
  12. <view style="padding-top: 7rpx;">
  13. <!-- 需要置顶 -->
  14. <uv-icon name="map-fill" color="#019245" size="28rpx"></uv-icon>
  15. </view>
  16. <text class="address-text">{{ teamLeader.area }} {{ teamLeader.address }}</text>
  17. </view>
  18. <view class="shop-phone">
  19. <view style="padding-top: 7rpx;">
  20. <!-- 需要置顶 -->
  21. <uv-icon name="phone-fill" color="#019245" size="28rpx"></uv-icon>
  22. </view>
  23. <text class="phone-text">{{teamLeader.phone}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="order-status">
  29. <!-- 商品列表 -->
  30. <view class="food-list">
  31. <view class="food-item" v-for="(food, index) in showedFoods" :key="food.id">
  32. <image class="food-image" :src="food.goods.image" mode="aspectFill" />
  33. <view class="food-info">
  34. <text class="food-name">{{food.goods.title}}</text>
  35. <view class="food-sold">
  36. <uv-icon name="bag" size="28rpx"></uv-icon>
  37. <text>已售出 {{ food.goods.sales }}</text>
  38. </view>
  39. <text class="food-price"> <text style="font-size: 20rpx;"></text> {{food.goods.price}}</text>
  40. <text class="food-count">×{{food.num}}</text>
  41. </view>
  42. </view>
  43. <view class="expand-more" @tap="showAllFoods = !showAllFoods" v-if="orderDetail.goodsList.length > 3">
  44. <text>{{showAllFoods ? '收起' : '展开'}} ({{orderDetail.goodsList.length}})</text>
  45. <uv-icon :name="showAllFoods ? 'arrow-up' : 'arrow-down'" size="28rpx"></uv-icon>
  46. </view>
  47. </view>
  48. <!-- 订单信息 -->
  49. <view class="order-info">
  50. <view class="info-item">
  51. <text class="info-label">合计:</text>
  52. <text class="info-value price">{{ orderDetail.pricePay }}</text>
  53. </view>
  54. <view class="info-item">
  55. <text class="info-label">创建时间:</text>
  56. <text class="info-value">{{ orderDetail.createTime }}</text>
  57. </view>
  58. <view class="info-item">
  59. <text class="info-label">订单编号:</text>
  60. <text class="info-value">{{orderDetail.id}}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="discount-info-container">
  65. <!-- 优惠信息 -->
  66. <view class="discount-info">
  67. <view class="discount-header">
  68. <text>优惠</text>
  69. </view>
  70. <view class="discount-item">
  71. <view class="discount-left" v-if="orderDetail.pricePreferential">
  72. <image src="@/static/image/券.webp" mode="aspectFill" class="coupon-icon" />
  73. <view>新用户立减</view>
  74. </view>
  75. <text v-if="orderDetail.pricePreferential" class="discount-amount"> - {{orderDetail.pricePreferential}}</text>
  76. <text v-else class="none-discount-amount">未使用优惠卷</text>
  77. </view>
  78. </view>
  79. <!-- 备注 -->
  80. <view class="remark-section">
  81. <view class="remark-header">
  82. <text>备注</text>
  83. </view>
  84. <view class="remark-content">
  85. <input v-if="orderStatus === '0' " type="text" v-model="orderDetail.remark"
  86. placeholder="请输入您要备注的内容" placeholder-style="font-size: 28rpx" />
  87. <text v-else>{{orderDetail.remark || '无备注信息'}}</text>
  88. </view>
  89. </view>
  90. <!-- 支付方式 -->
  91. <uv-radio-group v-model="payMethod" v-if="orderStatus === '0' ">
  92. <view class="payment-methods">
  93. <view class="payment-item">
  94. <uv-icon name="weixin-circle-fill" size="70rpx" color="#019245" />
  95. <text class="payment-name">微信支付</text>
  96. <uv-radio activeColor="#019245" size="40rpx" name="0" />
  97. </view>
  98. <view class="payment-item">
  99. <uv-icon name="red-packet" size="70rpx" color="#019245" />
  100. <text class="payment-name">账户余额<text class="balance-text">(余额: {{ userInfo.balance }})</text></text>
  101. <!-- 钱不够就会禁用 -->
  102. <uv-radio activeColor="#019245" size="40rpx" name="1" :disabled="userInfo.balance < orderDetail.pricePay" />
  103. </view>
  104. </view>
  105. </uv-radio-group>
  106. <!-- 底部支付栏 -->
  107. <view class="bottom-bar">
  108. <view class="total-section">
  109. <text class="total-label">
  110. {{ (orderDetail.goodsList || []).length }}
  111. <text style="color: black;">合计</text>
  112. </text>
  113. <text class="total-price">{{ ( orderDetail.pricePay || 0 ).toFixed(2) || 0 }}</text>
  114. </view>
  115. <view class="pay-button" @tap="handlePay" v-if="orderStatus === '0' ">立即下单</view>
  116. <view class="pay-button" @tap="handleTake" v-if="orderStatus === '3'">取餐完成</view>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import navbar from '@/components/base/navbar.vue'
  123. import { mapState, mapMutations } from 'vuex'
  124. export default {
  125. components: {
  126. navbar
  127. },
  128. data() {
  129. return {
  130. id: '',
  131. payMethod: '0',
  132. showAllFoods: false,
  133. // orderStatus: '',
  134. orderDetail: {
  135. status: '',
  136. remark: '',
  137. goodsList: [],
  138. priceAll: 0,
  139. pricePay: 0,
  140. pricePreferential: 0,
  141. },
  142. cartDiscount: 0,
  143. teamLeader: {}
  144. }
  145. },
  146. computed: {
  147. ...mapState([ 'userInfo']),
  148. showedFoods() {
  149. return this.showAllFoods ? this.orderDetail.goodsList : (this.orderDetail.goodsList.length > 3 ? this.orderDetail.goodsList.slice(0, 3) : this.orderDetail.goodsList)
  150. },
  151. orderStatus() {
  152. return this.orderDetail.status
  153. },
  154. },
  155. onLoad(options) {
  156. // 如果是购物车调过来的结账页面
  157. if (options.id) {
  158. this.getOrderDetail(options.id)
  159. }
  160. },
  161. methods: {
  162. ...mapMutations([ 'clearCouponData']),
  163. // 返回上一页
  164. navigateBack() {
  165. uni.navigateBack()
  166. },
  167. // 获取订单详情
  168. getOrderDetail(id) {
  169. this.id = id
  170. this.$api('queryMemberOrderList', {
  171. id: this.id
  172. }, res => {
  173. if (res.code === 200) {
  174. this.orderDetail = res.result.records[0]
  175. this.teamLeader = res.result.records[0].teamLeader
  176. }
  177. })
  178. },
  179. // 处理支付
  180. handlePay() {
  181. uni.showLoading({
  182. title: '支付处理中...'
  183. })
  184. this.$api('payOrder',{
  185. payType: this.payMethod,
  186. orderId: this.id,
  187. }, res => {
  188. uni.hideLoading()
  189. if (res.code === 200) {
  190. if (this.payMethod == '0') {
  191. uni.requestPaymentWxPay(res)
  192. .then(n => {
  193. setTimeout(uni.redirectTo, 500, {
  194. url: '/pages/index/order?tabIndex=1'
  195. })
  196. })
  197. .catch(err => {
  198. uni.showToast({
  199. title: '支付失败',
  200. icon: 'error'
  201. })
  202. setTimeout(uni.redirectTo, 500, {
  203. url: '/pages/index/order?tabIndex=0'
  204. })
  205. })
  206. } else {
  207. uni.showModal({
  208. title: '提示',
  209. content: '确认使用余额支付吗?',
  210. confirmColor: '#019245',
  211. success: (result) => {
  212. if (result.confirm) {
  213. uni.showToast({
  214. title: '下单成功',
  215. icon: 'success'
  216. })
  217. setTimeout(uni.redirectTo, 700, {
  218. url: '/pages/index/order?tabIndex=1'
  219. })
  220. }
  221. }
  222. })
  223. }
  224. }
  225. })
  226. },
  227. // 取餐完成
  228. handleTake() {
  229. this.$api('finishMemberOrderById', {
  230. memberOrderId: this.id
  231. }, res => {
  232. if (res.code === 200) {
  233. uni.showToast({
  234. title: '取餐完成',
  235. icon: 'success'
  236. })
  237. setTimeout( () => {
  238. uni.navigateBack()
  239. }, 1000)
  240. }
  241. })
  242. }
  243. }
  244. }
  245. </script>
  246. <style lang="scss" scoped>
  247. .page {
  248. background-color: #f5f5f5;
  249. min-height: 100vh;
  250. padding-bottom: 120rpx;
  251. }
  252. .status-bar {
  253. background-color: #019245;
  254. padding: 30rpx;
  255. color: #fff;
  256. font-size: 32rpx;
  257. font-weight: 500;
  258. }
  259. .shop-info {
  260. background-color: #fff;
  261. margin: 20rpx;
  262. border-radius: 16rpx;
  263. padding: 20rpx;
  264. .shop-header {
  265. display: flex;
  266. align-items: center;
  267. // background-color: red;
  268. .shop-logo {
  269. width: 150rpx;
  270. height: 150rpx;
  271. // border-radius: 10rpx;
  272. margin-right: 20rpx;
  273. }
  274. .shop-name-container {
  275. flex: 1;
  276. .shop-name {
  277. font-size: 30rpx;
  278. font-weight: 500;
  279. margin-bottom: 10rpx;
  280. display: block;
  281. }
  282. .shop-address, .shop-phone {
  283. display: flex;
  284. align-items: start;
  285. font-size: 24rpx;
  286. color: $uni-color-third;
  287. margin-top: 8rpx;
  288. .address-text, .phone-text {
  289. margin-left: 8rpx;
  290. width: 80%;
  291. white-space: wrap;
  292. // overflow: hidden;
  293. // text-overflow: ellipsis;
  294. }
  295. }
  296. .shop-address-top{
  297. display: flex;
  298. align-items: start;
  299. background-color: red;
  300. // gap: 10rpx;
  301. }
  302. }
  303. }
  304. }
  305. .order-status{
  306. background-color: #fff;
  307. margin: 20rpx;
  308. border-radius: 16rpx;
  309. padding: 20rpx;
  310. .food-list {
  311. // gap: 20rpx;
  312. // background-color: #019245;
  313. .food-item {
  314. display: flex;
  315. margin-bottom: 20rpx;
  316. // background-color: red;
  317. .food-image {
  318. width: 120rpx;
  319. height: 120rpx;
  320. // border-radius: 10rpx;
  321. margin-right: 20rpx;
  322. }
  323. .food-info {
  324. flex: 1;
  325. display: flex;
  326. flex-direction: column;
  327. justify-content: space-between;
  328. position: relative;
  329. .food-name {
  330. font-size: 28rpx;
  331. font-weight: 500;
  332. }
  333. .food-sold {
  334. display: flex;
  335. align-items: center;
  336. font-size: 24rpx;
  337. color: $uni-color-third;
  338. }
  339. .food-price {
  340. font-size: 28rpx;
  341. color: #f00;
  342. }
  343. .food-count {
  344. color: black;
  345. position: absolute;
  346. bottom: 50%;
  347. right: 0;
  348. }
  349. }
  350. }
  351. .expand-more {
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. padding: 20rpx 0 0;
  356. font-size: 24rpx;
  357. color: $uni-color-third;
  358. }
  359. }
  360. .order-info {
  361. padding-top: 20rpx;
  362. .info-item {
  363. display: flex;
  364. justify-content: space-between;
  365. margin-bottom: 15rpx;
  366. font-size: 26rpx;
  367. .info-label {
  368. color: black;
  369. }
  370. .info-value {
  371. color: #333;
  372. &.price {
  373. color: #f00;
  374. font-weight: 500;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .discount-info-container {
  381. background-color: #fff;
  382. margin: 20rpx;
  383. border-radius: 16rpx;
  384. padding: 20rpx;
  385. display: flex;
  386. flex-direction: column;
  387. gap: 40rpx;
  388. }
  389. .discount-info {
  390. display: flex;
  391. align-items: center;
  392. justify-content: space-between;
  393. .discount-header {
  394. font-size: 28rpx;
  395. }
  396. .discount-item {
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. gap: 20rpx;
  401. .discount-left {
  402. display: flex;
  403. align-items: center;
  404. gap: 10rpx;
  405. .coupon-icon {
  406. width: 36rpx;
  407. height: 36rpx;
  408. margin-top: 6rpx;
  409. }
  410. }
  411. .discount-amount {
  412. color: #f00;
  413. font-weight: 500;
  414. }
  415. .none-discount-amount{
  416. color: gray;
  417. font-weight: 500;
  418. }
  419. }
  420. }
  421. .remark-section {
  422. display: flex;
  423. // flex-direction: column;
  424. gap: 40rpx;
  425. // background-color: red;
  426. align-items: center;
  427. .remark-header {
  428. font-size: 28rpx;
  429. // font-weight: 500;
  430. }
  431. .remark-content {
  432. font-size: 26rpx;
  433. color: black;
  434. min-height: 60rpx;
  435. display: flex;
  436. align-items: center;
  437. }
  438. }
  439. .payment-methods {
  440. background-color: #fff;
  441. width: 100%;
  442. margin: 20rpx;
  443. border-radius: 16rpx;
  444. padding: 20rpx;
  445. display: flex;
  446. flex-direction: column;
  447. gap: 20rpx;
  448. .payment-item {
  449. display: flex;
  450. align-items: center;
  451. padding: 20rpx 0;
  452. border-bottom: 1rpx solid #f5f5f5;
  453. &:last-child {
  454. border-bottom: none;
  455. }
  456. .payment-name {
  457. flex: 1;
  458. margin-left: 20rpx;
  459. font-size: 28rpx;
  460. .balance-text {
  461. font-size: 24rpx;
  462. color: $uni-color-third;
  463. margin-left: 10rpx;
  464. }
  465. }
  466. }
  467. }
  468. .bottom-bar {
  469. position: fixed;
  470. bottom: 0;
  471. left: 0;
  472. right: 0;
  473. height: 100rpx;
  474. background-color: #fff;
  475. display: flex;
  476. align-items: center;
  477. padding: 0 30rpx;
  478. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  479. .total-section {
  480. flex: 1;
  481. .total-label {
  482. font-size: 26rpx;
  483. color: $uni-color-third;
  484. }
  485. .total-price {
  486. font-size: 32rpx;
  487. color: #f00;
  488. margin-left: 10rpx;
  489. }
  490. }
  491. .pay-button {
  492. width: 240rpx;
  493. height: 80rpx;
  494. background-color: #019245;
  495. color: #fff;
  496. font-size: 30rpx;
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. border-radius: 40rpx;
  501. }
  502. }
  503. </style>