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

391 lines
12 KiB

1 week ago
1 week ago
1 month ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. <template>
  2. <view class="place-order">
  3. <uv-popup ref="popup" @change="change" mode="bottom">
  4. <view class="place-order-content">
  5. <view class="place-order-title">
  6. <image src="@/static/image/多人下单.webp" mode="aspectFit" class="place-order-title-image" />
  7. <text class="number">{{ item.sales }}</text><text class="text">人下单</text>
  8. <view class="place-order-title-close" @click="close">
  9. <uv-icon name="close" size="40rpx" />
  10. </view>
  11. </view>
  12. <!-- 选择取餐地点 -->
  13. <view class="place-order-address" @click="gotoPickupPoint">
  14. <uv-icon name="map-fill" color="#019245" size="55rpx" />
  15. <text style="font-size: 42rpx;" v-show="!pickupPoint">
  16. 请选择取餐地点
  17. </text>
  18. <view v-if="pickupPoint" class="place-order-address-content">
  19. <view class="place-order-address-content-name">
  20. {{ pickupPoint.name }}{{ pickupPoint.phone }}
  21. </view>
  22. <view class="place-order-address-content-address"> {{ pickupPoint.area }} {{ pickupPoint.address
  23. }} </view>
  24. </view>
  25. <view class="place-order-address-arrow">
  26. <uv-icon name="arrow-right" size="40rpx" />
  27. </view>
  28. </view>
  29. <uv-gap height="20rpx" bgColor="#F7F7F7" />
  30. <!-- 货品信息 -->
  31. <view class="item">
  32. <image :src="item.image" mode="aspectFill" class="item-image"></image>
  33. <view style="font-size: 36rpx;">
  34. <view>{{ item.title }}</view>
  35. <view style="color: red; ">{{ (priceAll || 0).toFixed(2) }}</view>
  36. <view style="margin-top: 30rpx;">
  37. <uv-number-box v-model="value" button-size="36"></uv-number-box>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 选项框 -->
  42. <uv-radio-group v-model="payMethod">
  43. <view class="option-box">
  44. <view class="option-box-item">
  45. <uv-icon name="weixin-circle-fill" size="70rpx" color="#019245" />
  46. <text style="flex: 1;">
  47. 微信支付
  48. </text>
  49. <uv-radio activeColor="#019245" size="40rpx" name="0" />
  50. </view>
  51. <view class="option-box-item">
  52. <uv-icon name="red-packet" size="70rpx" color="#019245" />
  53. <text style="flex: 1;">
  54. 账户余额
  55. <text style="color: gray; margin-left: 20rpx;">(余额: {{ (userInfo.balance ||
  56. 0).toFixed(2) }})</text>
  57. </text>
  58. <uv-radio activeColor="#019245" size="40rpx" name="1"
  59. :disabled="userInfo.balance < pricePay" />
  60. </view>
  61. </view>
  62. </uv-radio-group>
  63. <uv-gap height="20rpx" bgColor="#F7F7F7" />
  64. <!-- 优惠 -->
  65. <view class="discount">
  66. <text style="font-size: 35rpx;">优惠</text>
  67. <view style="display: flex; align-items: center; gap: 20rpx" @click="gotoCoupon">
  68. <image src="@/static/image/券.webp" mode="aspectFill" class="discount-image"
  69. v-if="couponData.id" />
  70. <text v-if="couponData.id">{{ couponData.couponId_dictText || '优惠卷' }}</text>
  71. <text v-else style="color: gray;">请选择您的优惠卷</text>
  72. <text style="color: red;" v-if="couponData.discount">-{{ couponData.discount || 0 }}</text>
  73. </view>
  74. </view>
  75. <uv-gap height="20rpx" bgColor="#F7F7F7" />
  76. <!-- 备注 -->
  77. <view class="remark">
  78. <text style="align-self: start;">备注</text>
  79. <textarea class="remark-textarea" placeholder="请输入您需要备注的内容" v-model="remark" />
  80. </view>
  81. <!-- 购物车与支付 -->
  82. <view class="cart-pay">
  83. <view class="cart" @click="$emit('addCart')">
  84. <uv-icon name="shopping-cart-fill" size="60rpx" color="#019245" label="加入购物车" labelPos="bottom"
  85. labelSize="25rpx" />
  86. </view>
  87. <view class="total-section">
  88. <text>合计</text>
  89. <text class="total-price">{{ (pricePay || 0).toFixed(2) }}</text>
  90. </view>
  91. <view class="pay" @tap="createOrder">
  92. 立即支付
  93. </view>
  94. </view>
  95. </view>
  96. </uv-popup>
  97. </view>
  98. </template>
  99. <script>
  100. import { mapState } from 'vuex'
  101. import order from '@/mixins/order'
  102. export default {
  103. mixins: [order],
  104. name: 'placeOrder',
  105. data() {
  106. return {
  107. value: 1,
  108. payMethod: '0',
  109. pickupPoint: null,
  110. remark: '',
  111. }
  112. },
  113. props: {
  114. item: {
  115. type: Object,
  116. default: () => {}
  117. }
  118. },
  119. computed: {
  120. ...mapState(['userInfo', 'couponData']),
  121. priceAll () {
  122. return this.item?.price * this.value || 0
  123. },
  124. goodss () {
  125. return this.item?.id ? `${this.item.id},${this.value},${this.priceAll};` : ''
  126. },
  127. pricePay () {
  128. const discount = this.couponData?.discount || 0
  129. return (this.priceAll - discount) > 0.01 ? (this.priceAll - discount) : 0.01
  130. },
  131. orderParams () {
  132. return {
  133. priceAll: this.priceAll,
  134. pricePay: this.pricePay,
  135. pricePreferential: this.couponData?.discount || 0,
  136. payType: this.payMethod,
  137. leaderId: this.pickupPoint?.id || '',
  138. userCouponId: this.couponData?.id || '',
  139. goodss: this.goodss,
  140. remark: this.remark
  141. }
  142. }
  143. },
  144. methods: {
  145. // ...mapMutations(['clearCouponData']),
  146. // 跳转到优惠卷选择页面
  147. gotoCoupon() {
  148. this.$utils.navigateTo('/pages_order/mine/coupon?usein=1')
  149. },
  150. // 添加open方法,用于外部调用打开弹窗
  151. open() {
  152. // 判断绑定团长没有
  153. this.$api('queryMyLeader', {}, res => {
  154. this.$refs.popup.open();
  155. if (res.code == 200 && res.result.bindStatus != '2') {
  156. this.pickupPoint = res.result
  157. } else {
  158. uni.showModal({
  159. title: '提示',
  160. content: '您还没有绑定团长,请先绑定团长',
  161. confirmColor: '#019245',
  162. success: (res) => {
  163. if (res.confirm) {
  164. this.$utils.navigateTo('/pages_order/mine/unbindTeam')
  165. }
  166. this.$refs.popup.close()
  167. },
  168. })
  169. }
  170. })
  171. },
  172. // 添加close方法,用于关闭弹窗
  173. close(){
  174. this.$refs.popup.close();
  175. },
  176. // 添加change方法,用于处理弹窗状态变化
  177. change(e) {
  178. console.log('弹窗状态变化:', e);
  179. // 可以在这里添加弹窗打开或关闭后的逻辑处理
  180. },
  181. // 跳转到取餐点选择页面
  182. gotoPickupPoint() {
  183. this.$utils.navigateTo('/pages_order/mine/unbindTeam')
  184. },
  185. // 创建订单
  186. createOrder(){
  187. if (!this.pickupPoint) {
  188. uni.showModal({
  189. title: '提示',
  190. content: '请绑定团长',
  191. showCancel: false,
  192. confirmColor: '#019245',
  193. success: () => {
  194. this.gotoPickupPoint()
  195. }
  196. })
  197. return
  198. }
  199. if (this.payMethod == '1' && this.userInfo && this.userInfo.balance < this.pricePay) {
  200. uni.showModal({
  201. title: '余额不足',
  202. showCancel: false,
  203. content: '前往充值',
  204. confirmColor: '#019245',
  205. success: () => {
  206. this.$utils.navigateTo('/pages_order/mine/wallet')
  207. }
  208. })
  209. return
  210. }
  211. this.handlePay(this.orderParams)
  212. }
  213. },
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .place-order-title{
  218. font-size: 35rpx;
  219. height: 90rpx;
  220. display: flex;
  221. align-items: center;
  222. justify-content: center;
  223. position: relative;
  224. .number{
  225. color: $uni-color;
  226. }
  227. .text{
  228. color: #000;
  229. }
  230. .place-order-title-image{
  231. width: 100rpx;
  232. height: 50rpx;
  233. }
  234. .place-order-title-close{
  235. position: absolute;
  236. right: 20rpx;
  237. top: 50%;
  238. transform: translateY(-50%);
  239. color: $uni-color-third;
  240. }
  241. }
  242. .place-order-address{
  243. display: flex;
  244. height: 80rpx;
  245. line-height: 80rpx;
  246. align-items: center;
  247. // background-color: red;
  248. gap: 30rpx;
  249. padding-left: 20rpx;
  250. position: relative;
  251. text{
  252. font-size: 32rpx;
  253. font-weight: 500;
  254. }
  255. &-arrow{
  256. position: absolute;
  257. right: 20rpx;
  258. top: 50%;
  259. transform: translateY(-50%);
  260. }
  261. &-content{
  262. display: flex;
  263. flex-direction: column;
  264. justify-content: space-around;
  265. gap: 0rpx;
  266. height: 100%;
  267. // width: 100%;
  268. &-name{
  269. height: 30rpx;
  270. line-height: 30rpx;
  271. }
  272. &-address{
  273. height: 30rpx;
  274. line-height: 30rpx;
  275. width: 90%;
  276. text-overflow: ellipsis; // 三个连着一起才会出现省略号
  277. overflow: hidden;
  278. white-space: nowrap;
  279. }
  280. }
  281. }
  282. .item{
  283. display: flex;
  284. padding: 40rpx;
  285. gap: 40rpx;
  286. &-image{
  287. width: 250rpx;
  288. height: 200rpx;
  289. }
  290. }
  291. .option-box{
  292. display: flex;
  293. flex-direction: column;
  294. gap: 40rpx;
  295. width: 100%;
  296. &-item{
  297. display: flex;
  298. gap: 20rpx;
  299. align-items: center;
  300. font-size: 32rpx;
  301. padding: 0 40rpx;
  302. }
  303. }
  304. .discount{
  305. height: 130rpx;
  306. display: flex;
  307. align-items: center;
  308. width: 90%;
  309. justify-content: space-between;
  310. padding:0rpx 40rpx 0rpx 40rpx;
  311. // gap: 20rpx;
  312. .discount-image{
  313. width: 36rpx;
  314. height: 36rpx;
  315. border-radius: 10rpx;
  316. }
  317. }
  318. .remark{
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. padding: 20rpx 40rpx;
  323. // background-color: red;
  324. text{
  325. font-size: 32rpx;
  326. font-weight: 500;
  327. }
  328. .remark-textarea{
  329. width: 80%;
  330. height: 180rpx;
  331. // border: 1rpx solid #000;
  332. // border-radius: 10rpx;
  333. // padding: 20rpx;
  334. }
  335. }
  336. .cart-pay{
  337. // background-color: red;
  338. height: 130rpx;
  339. display: flex;
  340. .cart{
  341. width: 30%;
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. }
  346. .total-section{
  347. width: 30%;
  348. display: flex;
  349. flex-direction: column;
  350. align-items: center;
  351. justify-content: center;
  352. text{
  353. font-size: 28rpx;
  354. &.total-price{
  355. color: #ff0000;
  356. font-size: 32rpx;
  357. font-weight: 500;
  358. }
  359. }
  360. }
  361. .pay{
  362. width: 40%;
  363. background-color: $uni-color;
  364. color: #fff;
  365. text-align: center;
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. font-size: 32rpx;
  370. }
  371. }
  372. </style>