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

774 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
3 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. overflow: auto;
  385. padding-bottom: 300rpx;
  386. .bac {
  387. width: 100%;
  388. height: 100px;
  389. background: $uni-color;
  390. }
  391. .give-type {
  392. background: #fff;
  393. border-radius: 20rpx;
  394. padding: 30rpx;
  395. margin-bottom: 20rpx;
  396. .tab-box {
  397. display: flex;
  398. justify-content: space-between;
  399. .tab-item {
  400. width: 30%;
  401. background: #F8F8F8;
  402. border-radius: 20rpx;
  403. padding: 20rpx;
  404. text-align: center;
  405. text {
  406. display: block;
  407. &.desc {
  408. font-size: 24rpx;
  409. color: #999;
  410. margin-top: 10rpx;
  411. }
  412. }
  413. &.active {
  414. background: rgba($uni-color, 0.1);
  415. color: $uni-color;
  416. .desc {
  417. color: $uni-color;
  418. }
  419. }
  420. }
  421. }
  422. .tips {
  423. margin-top: 20rpx;
  424. font-size: 26rpx;
  425. color: #999;
  426. display: flex;
  427. align-items: center;
  428. justify-content: space-between;
  429. .guide {
  430. color: $uni-color;
  431. text-decoration: underline;
  432. }
  433. }
  434. }
  435. .box {
  436. padding: 20rpx;
  437. margin-top: -150rpx;
  438. // 商品详情
  439. .product-item {
  440. display: flex;
  441. flex-wrap: wrap;
  442. align-items: center;
  443. justify-content: space-between;
  444. background: white;
  445. border-radius: 15rpx;
  446. box-sizing: border-box;
  447. padding: 25rpx;
  448. margin: 20rpx 0rpx;
  449. .img-box {
  450. width: 200rpx;
  451. height: 200rpx;
  452. background: #ccc;
  453. border-radius: 10rpx;
  454. overflow: hidden;
  455. image {
  456. width: 100%;
  457. height: 100%;
  458. }
  459. }
  460. .server-info {
  461. width: calc(100% - 200rpx);
  462. box-sizing: border-box;
  463. padding: 10rpx 20rpx;
  464. display: flex;
  465. flex-direction: column;
  466. justify-content: space-around;
  467. .server-title {
  468. font-size: 34rpx;
  469. }
  470. .texture {
  471. color: #B8B8B8;
  472. margin: 10rpx 0rpx;
  473. }
  474. .stepper {
  475. margin-bottom: 10rpx;
  476. &::v-deep .uv-number-box__input {
  477. color: $uni-color !important;
  478. width: 100rpx !important;
  479. }
  480. }
  481. .sales-volume {
  482. display: flex;
  483. align-items: center;
  484. color: #B8B8B8;
  485. font-size: 26rpx;
  486. image {
  487. width: 25rpx;
  488. height: 25rpx;
  489. }
  490. }
  491. }
  492. }
  493. //cell单元格(地址)
  494. .cell-item {
  495. display: flex;
  496. justify-content: space-between;
  497. align-items: center;
  498. background: white;
  499. border-radius: 20rpx;
  500. padding: 20rpx;
  501. box-sizing: border-box;
  502. .cell-item-left {
  503. display: flex;
  504. align-items: center;
  505. width: 90%;
  506. .cell-icon {
  507. width: 40rpx;
  508. }
  509. .user-name,
  510. .user-address {
  511. white-space: nowrap;
  512. overflow: hidden;
  513. text-overflow: ellipsis;
  514. width: 150rpx;
  515. padding-left: 20rpx;
  516. box-sizing: border-box;
  517. }
  518. .descript {
  519. color: #888888;
  520. }
  521. .user-address {
  522. width: calc(100% - 230rpx);
  523. }
  524. }
  525. .cell-item-right {
  526. width: 10%;
  527. display: flex;
  528. justify-content: flex-end;
  529. .stepper {
  530. display: flex;
  531. align-items: center;
  532. text {
  533. display: flex;
  534. align-items: center;
  535. justify-content: center;
  536. width: 44rpx;
  537. height: 44rpx;
  538. &.minus, &.plus {
  539. background: #F8F8F8;
  540. border-radius: 50%;
  541. font-size: 32rpx;
  542. &.disabled {
  543. color: #ccc;
  544. }
  545. }
  546. &.num {
  547. margin: 0 20rpx;
  548. color: $uni-color;
  549. font-size: 28rpx;
  550. }
  551. }
  552. }
  553. }
  554. }
  555. .cell-list {
  556. margin: 20rpx 0rpx;
  557. border-radius: 20rpx;
  558. overflow: hidden;
  559. .cell-item {
  560. border-radius: 0rpx;
  561. }
  562. }
  563. // 提示
  564. .hint {
  565. font-size: 26rpx;
  566. margin-top: 80rpx;
  567. color: #BFBFBF;
  568. }
  569. // 用户协议
  570. .agreement {
  571. display: flex;
  572. justify-content: center;
  573. align-items: center;
  574. padding: 10px 0;
  575. .van-checkbox {
  576. margin-right: 5rpx;
  577. }
  578. text {
  579. color: $uni-color;
  580. }
  581. }
  582. // 下单
  583. .submit {
  584. position: fixed;
  585. bottom: 0;
  586. left: 0;
  587. width: 100%;
  588. height: 60px;
  589. background-color: #fff;
  590. display: flex;
  591. justify-content: space-between;
  592. align-items: center;
  593. .price {
  594. color: #F39637;
  595. padding: 0 20px;
  596. }
  597. .btn {
  598. background: $uni-color;
  599. color: white;
  600. width: 120px;
  601. height: 45px;
  602. border-radius: 23px;
  603. font-size: 16px;
  604. display: flex;
  605. justify-content: center;
  606. align-items: center;
  607. }
  608. }
  609. }
  610. //新增地址按钮
  611. .add-btn {
  612. width: 100%;
  613. .button-submit {
  614. display: flex;
  615. align-items: center;
  616. justify-content: center;
  617. width: 596rpx;
  618. height: 90rpx;
  619. background: #E3441A;
  620. border-radius: 46rpx;
  621. margin: 20rpx auto;
  622. font-size: 28rpx;
  623. font-family: PingFang SC, PingFang SC-Regular;
  624. font-weight: 400;
  625. text-align: center;
  626. color: #ffffff;
  627. }
  628. }
  629. .multi-box, .lucky-box {
  630. background: #fff;
  631. border-radius: 20rpx;
  632. padding: 30rpx;
  633. margin-bottom: 20rpx;
  634. .title {
  635. font-size: 28rpx;
  636. font-weight: 500;
  637. margin-bottom: 20rpx;
  638. }
  639. }
  640. .multi-box {
  641. .stepper {
  642. display: flex;
  643. align-items: center;
  644. justify-content: center;
  645. text {
  646. display: flex;
  647. align-items: center;
  648. justify-content: center;
  649. width: 60rpx;
  650. height: 60rpx;
  651. &.minus, &.plus {
  652. background: #F8F8F8;
  653. border-radius: 50%;
  654. font-size: 36rpx;
  655. &.disabled {
  656. color: #ccc;
  657. }
  658. }
  659. &.num {
  660. margin: 0 40rpx;
  661. color: $uni-color;
  662. font-size: 32rpx;
  663. }
  664. }
  665. }
  666. }
  667. .lucky-box {
  668. .tips-list {
  669. .tip-item {
  670. font-size: 26rpx;
  671. color: #666;
  672. line-height: 2;
  673. }
  674. }
  675. }
  676. }
  677. </style>