敢为人鲜小程序前端代码仓库
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.

527 lines
15 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="购物车支付 " leftClick @leftClick="navigateBack" bgColor="#019245" color="#fff" />
  5. <!-- 店铺信息 -->
  6. <view class="shop-info" v-show="hasLeader">
  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="cartData.sendData.length > 3">
  44. <text>{{ showAllFoods ? '收起' : '展开' }} ({{ cartData.sendData.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">{{ thePriceAll.toFixed(2) || 0 }}</text> -->
  53. <text class="info-value price">{{ (cartData.priceAll || 0).toFixed(2) || 0 }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="discount-info-container">
  58. <!-- 优惠信息 -->
  59. <view class="discount-info">
  60. <view class="discount-header">
  61. <text>优惠</text>
  62. </view>
  63. <view class="discount-item" @click="gotoCoupon">
  64. <view class="discount-left">
  65. <image src="@/static/image/券.webp" mode="aspectFill" class="coupon-icon" v-if="couponData.couponId" />
  66. <view :style="{ color: couponData.couponId ? 'inherit' : 'gray' }">{{ couponData.couponId_dictText || '请选择优惠卷' }}
  67. </view>
  68. <text class="discount-amount">{{ couponData.discount ? ('-' + couponData.discount) : '' }}</text>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 备注 -->
  73. <view class="remark-section">
  74. <view class="remark-header">
  75. <text>备注</text>
  76. </view>
  77. <view class="remark-content">
  78. <input type="text" v-model="remark"
  79. placeholder="请输入您要备注的内容" placeholder-style="font-size: 28rpx" />
  80. </view>
  81. </view>
  82. <!-- 支付方式 -->
  83. <uv-radio-group v-model="payMethod">
  84. <view class="payment-methods">
  85. <view class="payment-item">
  86. <uv-icon name="weixin-circle-fill" size="70rpx" color="#019245" />
  87. <text class="payment-name">微信支付</text>
  88. <uv-radio activeColor="#019245" size="40rpx" name="0" />
  89. </view>
  90. <view class="payment-item" >
  91. <uv-icon name="red-packet" size="70rpx" color="#019245" />
  92. <text class="payment-name">账户余额<text class="balance-text">(余额: {{ (userInfo.balance || 0).toFixed(2) || 0 }})</text></text>
  93. <uv-radio activeColor="#019245" size="40rpx" name="1" :disabled="userInfo.balance < pricePay"/>
  94. </view>
  95. </view>
  96. </uv-radio-group>
  97. <!-- 底部支付栏 -->
  98. <view class="bottom-bar">
  99. <view class="total-section">
  100. <text class="total-label">
  101. {{ cartData.sendData.length }}
  102. <text style="color: black;">合计</text>
  103. </text>
  104. <text class="total-price">{{ (pricePay || 0).toFixed(2) || 0 }}</text>
  105. </view>
  106. <view class="pay-button" @tap="handlePay(orderParams)">立即下单</view>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. import navbar from '@/components/base/navbar.vue'
  113. import order from '@/mixins/order.js'
  114. import { mapState } from 'vuex'
  115. export default {
  116. mixins: [order],
  117. components: {
  118. navbar
  119. },
  120. data() {
  121. return {
  122. payMethod: '0',
  123. showAllFoods: false,
  124. teamLeader: {},
  125. thePriceAll: 0,
  126. remark: '',
  127. hasLeader: false
  128. }
  129. },
  130. computed: {
  131. ...mapState(['cartData', 'userInfo', 'couponData']),
  132. showedFoods() {
  133. return this.showAllFoods ? this.cartData.sendData : this.cartData.sendData.slice(0, 3)
  134. },
  135. pricePay() {
  136. return (this.cartData.priceAll - (this.couponData.discount || 0)) > 0.01 ? (this.cartData.priceAll - (this.couponData.discount || 0)) : 0.01
  137. },
  138. // 格式为 goodId,goodNum;goodId2,goodsNum
  139. goodss() {
  140. return this.cartData.sendData.map(item => {
  141. return `${item.goodsId},${item.num},${item.goods.price * item.num}`
  142. }).join(';')
  143. },
  144. // 下单参数
  145. orderParams() {
  146. return {
  147. priceAll: this.cartData.priceAll,
  148. pricePay: this.pricePay,
  149. pricePreferential: this.couponData.discount || 0,
  150. payType: this.payMethod,
  151. leaderId: this.teamLeader.id,
  152. goodss: this.goodss,
  153. userCouponId: this.couponData.couponId || '',
  154. remark: this.remark || ''
  155. }
  156. }
  157. },
  158. onShow() {
  159. this.getLeaderData()
  160. },
  161. methods: {
  162. // 返回上一页
  163. navigateBack() {
  164. uni.navigateBack()
  165. },
  166. // 获取团长信息
  167. getLeaderData() {
  168. this.$api('queryMyLeader', {}, res => {
  169. if (res.code === 200 && res.result.bindStatus !== '2') {
  170. this.teamLeader = res.result
  171. this.hasLeader = true
  172. }else {
  173. uni.showModal({
  174. title: '提示',
  175. content: res.message,
  176. confirmColor: '#019245',
  177. confirmText: '去绑定',
  178. cancelText: '晚点再绑',
  179. success: (result) => {
  180. console.log('弹窗操作结果', result);
  181. if (result.confirm) {
  182. this.$utils.navigateTo({
  183. url: '/pages_order/mine/unbindTeam'
  184. })
  185. } else {
  186. this.$utils.navigateBack()
  187. }
  188. },
  189. fail: (err) => {
  190. console.error('弹窗显示失败', err);
  191. }
  192. })
  193. }
  194. })
  195. },
  196. // 去优惠页面
  197. gotoCoupon() {
  198. // 只有在待支付订单的情况下 才会进入优惠卷页面进行选择
  199. this.$utils.navigateTo({
  200. url: '/pages_order/mine/coupon?usein=1'
  201. })
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .page {
  208. background-color: #f5f5f5;
  209. min-height: 100vh;
  210. padding-bottom: 120rpx;
  211. }
  212. .status-bar {
  213. background-color: #019245;
  214. padding: 30rpx;
  215. color: #fff;
  216. font-size: 32rpx;
  217. font-weight: 500;
  218. }
  219. .shop-info {
  220. background-color: #fff;
  221. margin: 20rpx;
  222. border-radius: 16rpx;
  223. padding: 20rpx;
  224. .shop-header {
  225. display: flex;
  226. align-items: center;
  227. // background-color: red;
  228. .shop-logo {
  229. width: 150rpx;
  230. height: 150rpx;
  231. // border-radius: 10rpx;
  232. margin-right: 20rpx;
  233. }
  234. .shop-name-container {
  235. flex: 1;
  236. .shop-name {
  237. font-size: 30rpx;
  238. font-weight: 500;
  239. margin-bottom: 10rpx;
  240. display: block;
  241. }
  242. .shop-address,
  243. .shop-phone {
  244. display: flex;
  245. align-items: start;
  246. font-size: 24rpx;
  247. color: $uni-color-third;
  248. margin-top: 8rpx;
  249. .address-text,
  250. .phone-text {
  251. margin-left: 8rpx;
  252. width: 80%;
  253. white-space: wrap;
  254. // overflow: hidden;
  255. // text-overflow: ellipsis;
  256. }
  257. }
  258. .shop-address-top {
  259. display: flex;
  260. align-items: start;
  261. background-color: red;
  262. // gap: 10rpx;
  263. }
  264. }
  265. }
  266. }
  267. .order-status {
  268. background-color: #fff;
  269. margin: 20rpx;
  270. border-radius: 16rpx;
  271. padding: 20rpx;
  272. .food-list {
  273. // gap: 20rpx;
  274. // background-color: #019245;
  275. .food-item {
  276. display: flex;
  277. margin-bottom: 20rpx;
  278. // background-color: red;
  279. .food-image {
  280. width: 120rpx;
  281. height: 120rpx;
  282. // border-radius: 10rpx;
  283. margin-right: 20rpx;
  284. }
  285. .food-info {
  286. flex: 1;
  287. display: flex;
  288. flex-direction: column;
  289. justify-content: space-between;
  290. position: relative;
  291. .food-name {
  292. font-size: 28rpx;
  293. font-weight: 500;
  294. }
  295. .food-sold {
  296. display: flex;
  297. align-items: center;
  298. font-size: 24rpx;
  299. color: $uni-color-third;
  300. }
  301. .food-price {
  302. font-size: 28rpx;
  303. color: #f00;
  304. }
  305. .food-count {
  306. color: black;
  307. position: absolute;
  308. bottom: 50%;
  309. right: 0;
  310. }
  311. }
  312. }
  313. .expand-more {
  314. display: flex;
  315. align-items: center;
  316. justify-content: center;
  317. padding: 20rpx 0 0;
  318. font-size: 24rpx;
  319. color: $uni-color-third;
  320. }
  321. }
  322. .order-info {
  323. padding-top: 20rpx;
  324. .info-item {
  325. display: flex;
  326. justify-content: space-between;
  327. margin-bottom: 15rpx;
  328. font-size: 26rpx;
  329. .info-label {
  330. color: black;
  331. }
  332. .info-value {
  333. color: #333;
  334. &.price {
  335. color: #f00;
  336. font-weight: 500;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. .discount-info-container {
  343. background-color: #fff;
  344. margin: 20rpx;
  345. border-radius: 16rpx;
  346. padding: 20rpx;
  347. display: flex;
  348. flex-direction: column;
  349. gap: 40rpx;
  350. }
  351. .discount-info {
  352. display: flex;
  353. align-items: center;
  354. justify-content: space-between;
  355. .discount-header {
  356. font-size: 28rpx;
  357. }
  358. .discount-item {
  359. display: flex;
  360. justify-content: space-between;
  361. align-items: center;
  362. gap: 20rpx;
  363. .discount-left {
  364. display: flex;
  365. align-items: center;
  366. gap: 10rpx;
  367. .coupon-icon {
  368. width: 36rpx;
  369. height: 36rpx;
  370. margin-top: 6rpx;
  371. }
  372. }
  373. .discount-amount {
  374. color: #f00;
  375. font-weight: 500;
  376. }
  377. .none-discount-amount {
  378. color: gray;
  379. font-weight: 500;
  380. }
  381. }
  382. }
  383. .remark-section {
  384. display: flex;
  385. // flex-direction: column;
  386. gap: 40rpx;
  387. // background-color: red;
  388. align-items: center;
  389. .remark-header {
  390. font-size: 28rpx;
  391. // font-weight: 500;
  392. }
  393. .remark-content {
  394. font-size: 26rpx;
  395. color: black;
  396. min-height: 60rpx;
  397. display: flex;
  398. align-items: center;
  399. }
  400. }
  401. .payment-methods {
  402. background-color: #fff;
  403. width: 100%;
  404. margin: 20rpx;
  405. border-radius: 16rpx;
  406. padding: 20rpx;
  407. display: flex;
  408. flex-direction: column;
  409. gap: 20rpx;
  410. .payment-item {
  411. display: flex;
  412. align-items: center;
  413. padding: 20rpx 0;
  414. border-bottom: 1rpx solid #f5f5f5;
  415. &:last-child {
  416. border-bottom: none;
  417. }
  418. .payment-name {
  419. flex: 1;
  420. margin-left: 20rpx;
  421. font-size: 28rpx;
  422. .balance-text {
  423. font-size: 24rpx;
  424. color: $uni-color-third;
  425. margin-left: 10rpx;
  426. }
  427. }
  428. }
  429. }
  430. .bottom-bar {
  431. position: fixed;
  432. bottom: 0;
  433. left: 0;
  434. right: 0;
  435. height: 100rpx;
  436. background-color: #fff;
  437. display: flex;
  438. align-items: center;
  439. padding: 0 30rpx;
  440. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  441. .total-section {
  442. flex: 1;
  443. .total-label {
  444. font-size: 26rpx;
  445. color: $uni-color-third;
  446. }
  447. .total-price {
  448. font-size: 32rpx;
  449. color: #f00;
  450. margin-left: 10rpx;
  451. }
  452. }
  453. .pay-button {
  454. width: 240rpx;
  455. height: 80rpx;
  456. background-color: #019245;
  457. color: #fff;
  458. font-size: 30rpx;
  459. display: flex;
  460. align-items: center;
  461. justify-content: center;
  462. border-radius: 40rpx;
  463. }
  464. }
  465. </style>