珠宝小程序前端代码
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.

773 lines
19 KiB

5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
3 months ago
5 months ago
5 months ago
3 months ago
3 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar :title="titleMap[type]" leftClick @leftClick="$utils.navigateBack" bgColor="#E3441A" color="#fff" />
  5. <view class="bac"></view>
  6. <view class="box">
  7. <!-- 送礼 -->
  8. <view class="give-type" v-if="type == 'give'">
  9. <view class="tab-box">
  10. <view class="tab-item" :class="{'active': isGive === 1}"
  11. @click="isGive = 1">
  12. <text>单人礼包</text>
  13. <text class="desc">送给1位好友可同时送多件礼品</text>
  14. </view>
  15. <view class="tab-item" :class="{'active': isGive === 2}"
  16. @click="isGive = 2">
  17. <text>多人礼包</text>
  18. <text class="desc">送给多位好友每人1件礼品</text>
  19. </view>
  20. <view class="tab-item" :class="{'active': isGive === 3}"
  21. @click="isGive = 3">
  22. <text>抽奖礼包</text>
  23. <text class="desc">好友抽奖中奖者获得礼品</text>
  24. </view>
  25. </view>
  26. <!-- <view class="tips">
  27. <text>支付后分享给好友收礼</text>
  28. <text class="guide" @click="$refs.popup.open('gift_guide')">指南</text>
  29. </view> -->
  30. </view>
  31. <!-- 多人礼包人数 -->
  32. <view class="cell-item" v-if="type == 'give' && isGive === 2">
  33. <view class="cell-item-left">
  34. <uv-icon name="gift" size="40" color="#E3441A"></uv-icon>
  35. <view class="user-name">礼包份数</view>
  36. </view>
  37. <view class="cell-item-right">
  38. <view class="stepper">
  39. <text class="minus" :class="{disabled: multiNum <= multiMinNum}"
  40. @click="multiNum > multiMinNum && multiNum--">-</text>
  41. <text class="num">{{multiNum}}</text>
  42. <text class="plus" :class="{disabled: multiNum >= multiMaxNum}"
  43. @click="multiNum < multiMaxNum && multiNum++">+</text>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 抽奖礼包说明 -->
  48. <view class="lucky-box" v-if="type == 'give' && isGive === 3">
  49. <view class="title">抽奖规则</view>
  50. <view class="tips-list">
  51. <view class="tip-item"> 好友参与抽奖</view>
  52. <view class="tip-item"> 系统随机抽取中奖者</view>
  53. <view class="tip-item"> 中奖者填写地址领取礼品</view>
  54. </view>
  55. </view>
  56. <!-- 商品详情 -->
  57. <view class="product-item" v-for="item in payOrderProduct" :key="item.id">
  58. <view class="img-box">
  59. <image :src="item.image" mode="aspectFill"></image>
  60. </view>
  61. <view class="server-info">
  62. <view class="server-title">{{ item.title }}</view>
  63. <view class="texture">
  64. 材质{{ item.subText }}
  65. </view>
  66. <view class="stepper">
  67. <uv-number-box button-size="60" v-model="item.num"></uv-number-box>
  68. </view>
  69. <view class="sales-volume">
  70. <view class="desc">已售出 {{ item.payNum }}</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 地址 -->
  75. <view @click="openAddress" class="cell-item">
  76. <view class="cell-item-left">
  77. <image src="@/pages_order/static/createOrder/address.png" mode="widthFix" class="cell-icon"></image>
  78. <view class="user-name">{{ address.name }}</view>
  79. <view class="user-address">{{ address.address }}</view>
  80. </view>
  81. <view class="cell-item-right">
  82. <uv-icon name="arrow-right"></uv-icon>
  83. </view>
  84. </view>
  85. <view class="cell-list">
  86. <uv-radio-group v-model="payMethod">
  87. <view style="width: 710rpx;">
  88. <!-- 账户余额 -->
  89. <view class="cell-item">
  90. <view class="cell-item-left">
  91. <image src="@/pages_order/static/createOrder/account.png" mode="widthFix" class="cell-icon">
  92. </image>
  93. <view class="user-name">账户余额</view>
  94. <view class="descript">(余额: {{ riceInfo.balance }})</view>
  95. </view>
  96. <view class="cell-item-right">
  97. <uv-radio activeColor="#E3441A"
  98. size="40rpx"
  99. icon-size="30rpx"
  100. :name="1"/>
  101. </view>
  102. </view>
  103. <!-- 微信支付 -->
  104. <view class="cell-item">
  105. <view class="cell-item-left">
  106. <image src="@/pages_order/static/createOrder/wx.png" mode="widthFix" class="cell-icon">
  107. </image>
  108. <view class="user-name">微信支付</view>
  109. <view class="descript"></view>
  110. </view>
  111. <view class="cell-item-right">
  112. <uv-radio
  113. activeColor="#E3441A"
  114. size="40rpx"
  115. icon-size="30rpx"
  116. :name="0"/>
  117. </view>
  118. </view>
  119. </view>
  120. </uv-radio-group>
  121. </view>
  122. <!-- 优惠券 -->
  123. <view @click="openCoupon" class="cell-item">
  124. <view class="cell-item-left">
  125. <image src="@/pages_order/static/createOrder/coupon.png" mode="widthFix" class="cell-icon"></image>
  126. <view class="user-name">优惠券</view>
  127. <view class="descript">({{ coupon.money || 0}})</view>
  128. </view>
  129. <view class="cell-item-right">
  130. <!-- <radio color="#E3441A" :value="2" :checked="coupon.id" /> -->
  131. </view>
  132. </view>
  133. <!-- 提示 -->
  134. <view class="hint"
  135. v-if="payOrderProduct[0] && payOrderProduct[0].orderDetails">
  136. {{ payOrderProduct[0].orderDetails }}
  137. </view>
  138. <!-- 用户协议 -->
  139. <view class="agreement">
  140. <radio color="#E3441A" @click="agreement = !agreement" :checked="agreement" />
  141. 本人已同意<text @click="$refs.popup.open('user_xy')">用户使用协议</text>
  142. </view>
  143. <!-- 下单 -->
  144. <view class="submit">
  145. <view class="price">
  146. <view>
  147. <text style="color: #000;">合计</text>
  148. <text style="font-size: 18px;
  149. font-weight: 600;">{{ totalPrice }}</text>
  150. </view>
  151. </view>
  152. <view class="btn" @click="submit">
  153. 立即支付
  154. </view>
  155. </view>
  156. </view>
  157. <!-- 地址选择 -->
  158. <uv-popup ref="addressPopup" :round="30" style="padding-bottom: 90rpx;">
  159. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  160. <view class="add-btn">
  161. <view @click="$utils.navigateTo('/pages_order/mine/address')" class="button-submit">新增地址</view>
  162. </view>
  163. </uv-popup>
  164. <!-- 优惠券选择-->
  165. <uv-popup ref="couponPopup" :round="30">
  166. <couponList ref="couponList" height="60vh" @select="selectCoupon" />
  167. </uv-popup>
  168. <configPopup ref="popup"></configPopup>
  169. </view>
  170. </template>
  171. <script>
  172. import addressList from '../components/address/addressList.vue'
  173. import couponList from '@/components/couponList/couponList.vue'
  174. import {
  175. mapState
  176. } from 'vuex'
  177. export default {
  178. components: {
  179. addressList,
  180. couponList
  181. },
  182. data() {
  183. return {
  184. address: {
  185. name: '请选择地址',
  186. address: '',
  187. },
  188. addressTotal: 0,
  189. remark: '',
  190. num: 1,
  191. agreement: false,
  192. coupon: {},
  193. payMethod : 0,
  194. isGive : 0,
  195. type : '',
  196. titleMap : {
  197. def : '确认订单',
  198. give : '送礼清单',
  199. },
  200. multiNum: 2, // 多人礼包人数
  201. multiMinNum: 2, // 最小人数
  202. multiMaxNum: 100, // 最大人数
  203. }
  204. },
  205. computed: {
  206. totalPrice() {
  207. let price = 0
  208. this.payOrderProduct.forEach(n => {
  209. price += n.price * n.num
  210. })
  211. if (this.coupon.id) {
  212. price -= this.coupon.money
  213. }
  214. return Number(price).toFixed(2)
  215. },
  216. ...mapState(['userInfo', 'payOrderProduct']),
  217. },
  218. onLoad(args) {
  219. this.type = args.type || 'def'
  220. if(this.type == 'give'){
  221. this.isGive = 1
  222. }
  223. this.$store.commit('getUserInfo')
  224. },
  225. onShow() {
  226. this.getAddressList()
  227. this.getCouponList()
  228. },
  229. methods: {
  230. // 打开
  231. getAddressList() {
  232. // 获取地址列表
  233. this.$refs.addressList.getAddressList().then(res => {
  234. this.addressTotal = res.total
  235. if (this.addressTotal != 0) {
  236. this.address = res.records[0]
  237. }
  238. })
  239. },
  240. //获取优惠券列表
  241. getCouponList() {
  242. this.$refs.couponList.getCouponList()
  243. },
  244. // 打开选择地址
  245. openAddress() {
  246. if (this.addressTotal == 0) {
  247. return uni.navigateTo({
  248. url: '/pages_order/mine/address?type=back'
  249. })
  250. }
  251. this.$refs.addressPopup.open('bottom')
  252. },
  253. // 选择地址
  254. selectAddress(e) {
  255. this.address = e
  256. this.$refs.addressPopup.close()
  257. },
  258. // 打开优惠券选择
  259. openCoupon() {
  260. if (this.addressTotal == 0) {
  261. return uni.navigateTo({
  262. url: '/pages_order/mine/address?type=back'
  263. })
  264. }
  265. this.$refs.couponPopup.open('bottom')
  266. },
  267. // 选择优惠券
  268. selectCoupon(e) {
  269. //判断优惠券限制
  270. let {
  271. useMoney
  272. } = e
  273. let productTotalPrice = 0
  274. this.payOrderProduct.forEach(item => {
  275. productTotalPrice += item.price
  276. })
  277. if (productTotalPrice < useMoney) {
  278. return uni.showToast({
  279. title: `此优惠券需要满${useMoney}使用`,
  280. icon: "none"
  281. })
  282. }
  283. this.coupon = e
  284. this.$refs.couponPopup.close()
  285. },
  286. submit() {
  287. let addressId = this.address.id
  288. if (!addressId) {
  289. uni.showToast({
  290. title: '请选择地址',
  291. icon: 'none'
  292. })
  293. return
  294. }
  295. if (!this.agreement) {
  296. uni.showToast({
  297. title: '请先同意使用协议',
  298. icon: 'none'
  299. })
  300. return
  301. }
  302. let data = {}
  303. let api = ''
  304. // 不是送礼
  305. if(this.type != 'give'){
  306. let list = []
  307. this.payOrderProduct.forEach(n => {
  308. list.push({
  309. num: n.num,
  310. shopId: n.shopId || n.id,
  311. })
  312. })
  313. data = {
  314. addressId,
  315. payType : this.payMethod,
  316. list: JSON.stringify(list),
  317. }
  318. api = 'createSumOrder'
  319. this.deleteCart(this.payOrderProduct.map(n => n.id).join(','))
  320. } else { //体验、常规商品
  321. data = {
  322. addressId,
  323. num: this.payOrderProduct[0].num,
  324. shopId: this.payOrderProduct[0].id,
  325. payType : this.payMethod,
  326. isGive : this.isGive,
  327. memberNum : 1,
  328. }
  329. api = 'createOrder'
  330. }
  331. if(this.coupon.id){
  332. data.couponId = this.coupon.id
  333. }
  334. if(this.isGive == 2){
  335. data.memberNum = this.multiNum
  336. }
  337. this.$api(api, data, res => {
  338. if (res.code == 200) {
  339. if(this.payMethod == 1){
  340. // uni.showToast({
  341. // title: '下单成功',
  342. // icon: 'none'
  343. // })
  344. this.paySuccess(res)
  345. return
  346. }
  347. uni.requestPaymentWxPay(res)
  348. .then(e => {
  349. uni.showToast({
  350. title: '下单成功',
  351. icon: 'none'
  352. })
  353. this.paySuccess(res)
  354. }).catch(n => {
  355. setTimeout(uni.redirectTo, 700, {
  356. url: '/pages/index/order'
  357. })
  358. })
  359. }
  360. })
  361. },
  362. paySuccess(res){
  363. if(this.type == 'def'){
  364. setTimeout(uni.redirectTo, 700, {
  365. url: '/pages/index/order'
  366. })
  367. }else{
  368. setTimeout(uni.redirectTo, 700, {
  369. url: `/pages_order/order/instantGift?id=${res.message}`
  370. })
  371. }
  372. },
  373. // 删除购物车
  374. deleteCart(ids) {
  375. this.$api('deleteCart', {
  376. ids
  377. })
  378. },
  379. }
  380. }
  381. </script>
  382. <style scoped lang="scss">
  383. .page {
  384. .bac {
  385. width: 100%;
  386. height: 100px;
  387. background: $uni-color;
  388. }
  389. .give-type {
  390. background: #fff;
  391. border-radius: 20rpx;
  392. padding: 30rpx;
  393. margin-bottom: 20rpx;
  394. .tab-box {
  395. display: flex;
  396. justify-content: space-between;
  397. .tab-item {
  398. width: 30%;
  399. background: #F8F8F8;
  400. border-radius: 20rpx;
  401. padding: 20rpx;
  402. text-align: center;
  403. text {
  404. display: block;
  405. &.desc {
  406. font-size: 24rpx;
  407. color: #999;
  408. margin-top: 10rpx;
  409. }
  410. }
  411. &.active {
  412. background: rgba($uni-color, 0.1);
  413. color: $uni-color;
  414. .desc {
  415. color: $uni-color;
  416. }
  417. }
  418. }
  419. }
  420. .tips {
  421. margin-top: 20rpx;
  422. font-size: 26rpx;
  423. color: #999;
  424. display: flex;
  425. align-items: center;
  426. justify-content: space-between;
  427. .guide {
  428. color: $uni-color;
  429. text-decoration: underline;
  430. }
  431. }
  432. }
  433. .box {
  434. padding: 20rpx;
  435. margin-top: -150rpx;
  436. // 商品详情
  437. .product-item {
  438. display: flex;
  439. flex-wrap: wrap;
  440. align-items: center;
  441. justify-content: space-between;
  442. background: white;
  443. border-radius: 15rpx;
  444. box-sizing: border-box;
  445. padding: 25rpx;
  446. margin: 20rpx 0rpx;
  447. .img-box {
  448. width: 200rpx;
  449. height: 200rpx;
  450. background: #ccc;
  451. border-radius: 10rpx;
  452. overflow: hidden;
  453. image {
  454. width: 100%;
  455. height: 100%;
  456. }
  457. }
  458. .server-info {
  459. width: calc(100% - 200rpx);
  460. box-sizing: border-box;
  461. padding: 10rpx 20rpx;
  462. display: flex;
  463. flex-direction: column;
  464. justify-content: space-around;
  465. .server-title {
  466. font-size: 34rpx;
  467. }
  468. .texture {
  469. color: #B8B8B8;
  470. margin: 10rpx 0rpx;
  471. }
  472. .stepper {
  473. margin-bottom: 10rpx;
  474. &::v-deep .uv-number-box__input {
  475. color: $uni-color !important;
  476. width: 100rpx !important;
  477. }
  478. }
  479. .sales-volume {
  480. display: flex;
  481. align-items: center;
  482. color: #B8B8B8;
  483. font-size: 26rpx;
  484. image {
  485. width: 25rpx;
  486. height: 25rpx;
  487. }
  488. }
  489. }
  490. }
  491. //cell单元格(地址)
  492. .cell-item {
  493. display: flex;
  494. justify-content: space-between;
  495. align-items: center;
  496. background: white;
  497. border-radius: 20rpx;
  498. padding: 20rpx;
  499. box-sizing: border-box;
  500. .cell-item-left {
  501. display: flex;
  502. align-items: center;
  503. width: 90%;
  504. .cell-icon {
  505. width: 40rpx;
  506. }
  507. .user-name,
  508. .user-address {
  509. white-space: nowrap;
  510. overflow: hidden;
  511. text-overflow: ellipsis;
  512. width: 150rpx;
  513. padding-left: 20rpx;
  514. box-sizing: border-box;
  515. }
  516. .descript {
  517. color: #888888;
  518. }
  519. .user-address {
  520. width: calc(100% - 230rpx);
  521. }
  522. }
  523. .cell-item-right {
  524. width: 10%;
  525. display: flex;
  526. justify-content: flex-end;
  527. .stepper {
  528. display: flex;
  529. align-items: center;
  530. text {
  531. display: flex;
  532. align-items: center;
  533. justify-content: center;
  534. width: 44rpx;
  535. height: 44rpx;
  536. &.minus, &.plus {
  537. background: #F8F8F8;
  538. border-radius: 50%;
  539. font-size: 32rpx;
  540. &.disabled {
  541. color: #ccc;
  542. }
  543. }
  544. &.num {
  545. margin: 0 20rpx;
  546. color: $uni-color;
  547. font-size: 28rpx;
  548. }
  549. }
  550. }
  551. }
  552. }
  553. .cell-list {
  554. margin: 20rpx 0rpx;
  555. border-radius: 20rpx;
  556. overflow: hidden;
  557. .cell-item {
  558. border-radius: 0rpx;
  559. }
  560. }
  561. // 提示
  562. .hint {
  563. font-size: 26rpx;
  564. margin-top: 80rpx;
  565. color: #BFBFBF;
  566. }
  567. // 用户协议
  568. .agreement {
  569. display: flex;
  570. justify-content: center;
  571. align-items: center;
  572. padding: 10px 0;
  573. .van-checkbox {
  574. margin-right: 5rpx;
  575. }
  576. text {
  577. color: $uni-color;
  578. }
  579. }
  580. // 下单
  581. .submit {
  582. position: fixed;
  583. bottom: 0;
  584. left: 0;
  585. width: 100%;
  586. height: 60px;
  587. background-color: #fff;
  588. display: flex;
  589. justify-content: space-between;
  590. align-items: center;
  591. .price {
  592. color: #F39637;
  593. padding: 0 20px;
  594. }
  595. .btn {
  596. background: $uni-color;
  597. color: white;
  598. width: 120px;
  599. height: 45px;
  600. border-radius: 23px;
  601. font-size: 16px;
  602. display: flex;
  603. justify-content: center;
  604. align-items: center;
  605. }
  606. }
  607. }
  608. //新增地址按钮
  609. .add-btn {
  610. width: 100%;
  611. .button-submit {
  612. display: flex;
  613. align-items: center;
  614. justify-content: center;
  615. width: 596rpx;
  616. height: 90rpx;
  617. background: #E3441A;
  618. border-radius: 46rpx;
  619. margin: 20rpx auto;
  620. font-size: 28rpx;
  621. font-family: PingFang SC, PingFang SC-Regular;
  622. font-weight: 400;
  623. text-align: center;
  624. color: #ffffff;
  625. }
  626. }
  627. .multi-box, .lucky-box {
  628. background: #fff;
  629. border-radius: 20rpx;
  630. padding: 30rpx;
  631. margin-bottom: 20rpx;
  632. .title {
  633. font-size: 28rpx;
  634. font-weight: 500;
  635. margin-bottom: 20rpx;
  636. }
  637. }
  638. .multi-box {
  639. .stepper {
  640. display: flex;
  641. align-items: center;
  642. justify-content: center;
  643. text {
  644. display: flex;
  645. align-items: center;
  646. justify-content: center;
  647. width: 60rpx;
  648. height: 60rpx;
  649. &.minus, &.plus {
  650. background: #F8F8F8;
  651. border-radius: 50%;
  652. font-size: 36rpx;
  653. &.disabled {
  654. color: #ccc;
  655. }
  656. }
  657. &.num {
  658. margin: 0 40rpx;
  659. color: $uni-color;
  660. font-size: 32rpx;
  661. }
  662. }
  663. }
  664. }
  665. .lucky-box {
  666. .tips-list {
  667. .tip-item {
  668. font-size: 26rpx;
  669. color: #666;
  670. line-height: 2;
  671. }
  672. }
  673. }
  674. }
  675. </style>