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

467 lines
9.3 KiB

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
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
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
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="确认订单" leftClick @leftClick="$utils.navigateBack" bgColor="#E3441A" color="#fff" />
  5. <view class="bac"></view>
  6. <view class="box">
  7. <!-- 商品详情 -->
  8. <view class="product-item">
  9. <view class="img-box">
  10. <image :src="projectDetail.image" mode="aspectFill"></image>
  11. </view>
  12. <view class="server-info">
  13. <view class="server-title">MOMEIREN双面黑钻项链</view>
  14. <view class="texture">
  15. 材质S25银
  16. </view>
  17. <view class="stepper">
  18. <uv-number-box button-size="60" v-model="value" @change="valChange"></uv-number-box>
  19. </view>
  20. <view class="sales-volume">
  21. <view class="desc">已售出 666+ </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 地址 -->
  26. <view @click="openAddress" class="cell-item">
  27. <view class="cell-item-left">
  28. <image src="@/pages_order/static/createOrder/address.png" mode="widthFix" class="cell-icon"></image>
  29. <view class="user-name">{{ address.name }}</view>
  30. <view class="user-address">{{ address.address}}</view>
  31. </view>
  32. <view class="cell-item-right">
  33. <uv-icon name="arrow-right"></uv-icon>
  34. </view>
  35. </view>
  36. <view class="cell-list">
  37. <!-- 账户余额 -->
  38. <view class="cell-item">
  39. <view class="cell-item-left">
  40. <image src="@/pages_order/static/createOrder/account.png" mode="widthFix" class="cell-icon">
  41. </image>
  42. <view class="user-name">账户余额</view>
  43. <view class="descript">(余额: {{ userInfo.money}})</view>
  44. </view>
  45. <view class="cell-item-right">
  46. </view>
  47. </view>
  48. <!-- 微信支付 -->
  49. <view class="cell-item">
  50. <view class="cell-item-left">
  51. <image src="@/pages_order/static/createOrder/wx.png" mode="widthFix" class="cell-icon">
  52. </image>
  53. <view class="user-name">微信支付</view>
  54. <view class="descript"></view>
  55. </view>
  56. <view class="cell-item-right">
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 优惠券 -->
  61. <view class="cell-item">
  62. <view class="cell-item-left">
  63. <image src="@/pages_order/static/createOrder/coupon.png" mode="widthFix" class="cell-icon"></image>
  64. <view class="user-name">优惠券</view>
  65. <view class="descript">$20</view>
  66. </view>
  67. <view class="cell-item-right">
  68. </view>
  69. </view>
  70. <!-- 提示 -->
  71. <view class="hint">
  72. 温馨提示下单前请仔细查看下单需知
  73. </view>
  74. <!-- 用户协议 -->
  75. <view class="agreement">
  76. <radio @click="agreement = !agreement" :checked="agreement" />
  77. 本人已同意<text @click="configPopupShow = true">用户使用协议</text>
  78. </view>
  79. <!-- 下单 -->
  80. <view class="submit">
  81. <view class="price">
  82. <view>
  83. <text style="color: #000;">合计</text>
  84. <text style="font-size: 18px;
  85. font-weight: 600;">{{ count }}</text>
  86. </view>
  87. </view>
  88. <view class="btn" @click="submit">
  89. 立即支付
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 地址选择 -->
  94. <uv-popup ref="addressPopup" :round="30">
  95. <addressList ref="addressList" height="60vh" @select="selectAddress" />
  96. </uv-popup>
  97. </view>
  98. </template>
  99. <script>
  100. import addressList from '../components/address/addressList.vue'
  101. import {
  102. mapState
  103. } from 'vuex'
  104. export default {
  105. components: {
  106. addressList,
  107. },
  108. data() {
  109. return {
  110. productList: [],
  111. address: {
  112. name: '请选择地址',
  113. address: '',
  114. },
  115. addressTotal: 0,
  116. remark: '',
  117. num: 1,
  118. agreement: true
  119. }
  120. },
  121. computed: {
  122. totalPrice() {
  123. let price = 0
  124. this.productList.forEach(n => {
  125. if ([2].includes(n.type) && [1].includes(this.userInfo.isPay)) {
  126. // 常规、普通商品的同时用户是会员就计算会员价
  127. price += n.vipPrice * n.num
  128. } else {
  129. // 普通价格
  130. price += n.price * n.num
  131. }
  132. })
  133. return Number(price).toFixed(2)
  134. },
  135. ...mapState(['payOrderProduct', 'userInfo']),
  136. },
  137. onLoad() {
  138. this.getRiceProductDetail()
  139. this.$store.commit('getUserInfo')
  140. },
  141. onShow() {
  142. this.getAddressList()
  143. },
  144. methods: {
  145. // 获取商品
  146. getRiceProductDetail() {
  147. this.productList = JSON.parse(JSON.stringify(this.payOrderProduct))
  148. },
  149. // 打开
  150. getAddressList() {
  151. // 获取地址列表
  152. this.$refs.addressList.getAddressList().then(res => {
  153. this.addressTotal = res.total
  154. if (this.addressTotal != 0) {
  155. this.address = res.records[0]
  156. }
  157. })
  158. },
  159. // 打开选择地址
  160. openAddress() {
  161. if (this.addressTotal == 0) {
  162. return uni.navigateTo({
  163. url: '/pages_order/mine/address?type=back'
  164. })
  165. }
  166. this.$refs.addressPopup.open('bottom')
  167. },
  168. // 选择地址
  169. selectAddress(e) {
  170. this.address = e
  171. this.$refs.addressPopup.close()
  172. },
  173. submit() {
  174. let addressId = this.address.id
  175. if (!addressId) {
  176. uni.showToast({
  177. title: '请选择地址',
  178. icon: 'none'
  179. })
  180. return
  181. }
  182. let data = {}
  183. let api = ''
  184. if (this.productList[0].shopId || this.productList[0].type == 2) { //普通商品
  185. let list = []
  186. this.productList.forEach(n => {
  187. list.push({
  188. num: n.num,
  189. shopId: n.shopId || n.id,
  190. })
  191. })
  192. data = {
  193. addressId,
  194. list: JSON.stringify(list),
  195. }
  196. api = 'createSumOrder'
  197. this.deleteCart(this.productList.map(n => n.id).join(','))
  198. } else { //体验、常规商品
  199. data = {
  200. addressId,
  201. num: this.productList[0].num,
  202. shopId: this.productList[0].id,
  203. }
  204. api = 'createOrder'
  205. }
  206. this.$api(api, data, res => {
  207. if (res.code == 200) {
  208. uni.requestPaymentWxPay(res)
  209. .then(res => {
  210. uni.showToast({
  211. title: '下单成功',
  212. icon: 'none'
  213. })
  214. setTimeout(uni.redirectTo, 700, {
  215. url: '/pages/index/order'
  216. })
  217. }).catch(n => {
  218. setTimeout(uni.redirectTo, 700, {
  219. url: '/pages/index/order'
  220. })
  221. })
  222. } else if (res.code == 902) {
  223. uni.showModal({
  224. title: res.message,
  225. success(e) {
  226. if (e.confirm) {
  227. uni.redirectTo({
  228. url: '/pages/index/order'
  229. })
  230. }
  231. }
  232. })
  233. }
  234. })
  235. },
  236. // 删除购物车
  237. deleteCart(ids) {
  238. this.$api('deleteCart', {
  239. ids
  240. })
  241. },
  242. }
  243. }
  244. </script>
  245. <style scoped lang="scss">
  246. .page {
  247. .bac {
  248. width: 100%;
  249. height: 100px;
  250. background: $uni-color;
  251. }
  252. .box {
  253. padding: 20rpx;
  254. margin-top: -150rpx;
  255. // 商品详情
  256. .product-item {
  257. display: flex;
  258. flex-wrap: wrap;
  259. align-items: center;
  260. justify-content: space-between;
  261. background: white;
  262. border-radius: 15rpx;
  263. box-sizing: border-box;
  264. padding: 25rpx;
  265. margin: 20rpx 0rpx;
  266. .img-box {
  267. width: 200rpx;
  268. height: 200rpx;
  269. background: #ccc;
  270. border-radius: 10rpx;
  271. overflow: hidden;
  272. image {
  273. width: 100%;
  274. height: 100%;
  275. }
  276. }
  277. .server-info {
  278. width: calc(100% - 200rpx);
  279. box-sizing: border-box;
  280. padding: 10rpx 20rpx;
  281. display: flex;
  282. flex-direction: column;
  283. justify-content: space-around;
  284. .server-title {
  285. font-size: 34rpx;
  286. }
  287. .texture {
  288. color: #B8B8B8;
  289. margin: 10rpx 0rpx;
  290. }
  291. .stepper {
  292. margin-bottom: 10rpx;
  293. &::v-deep .uv-number-box__input {
  294. color: $uni-color !important;
  295. }
  296. }
  297. .sales-volume {
  298. display: flex;
  299. align-items: center;
  300. color: #B8B8B8;
  301. font-size: 26rpx;
  302. image {
  303. width: 25rpx;
  304. height: 25rpx;
  305. }
  306. }
  307. }
  308. }
  309. //cell单元格(地址)
  310. .cell-item {
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. background: white;
  315. border-radius: 20rpx;
  316. padding: 20rpx;
  317. box-sizing: border-box;
  318. .cell-item-left {
  319. display: flex;
  320. align-items: center;
  321. width: 90%;
  322. .cell-icon {
  323. width: 40rpx;
  324. }
  325. .user-name,
  326. .user-address {
  327. white-space: nowrap;
  328. overflow: hidden;
  329. text-overflow: ellipsis;
  330. width: 150rpx;
  331. padding-left: 20rpx;
  332. box-sizing: border-box;
  333. }
  334. .descript {
  335. color: #888888;
  336. }
  337. .user-address {
  338. width: calc(100% - 230rpx);
  339. }
  340. }
  341. .cell-item-right {
  342. width: 10%;
  343. display: flex;
  344. justify-content: flex-end;
  345. }
  346. }
  347. .cell-list {
  348. margin: 20rpx 0rpx;
  349. border-radius: 20rpx;
  350. overflow: hidden;
  351. .cell-item {
  352. border-radius: 0rpx;
  353. }
  354. }
  355. // 提示
  356. .hint {
  357. font-size: 26rpx;
  358. margin-top: 60rpx;
  359. color: #BFBFBF;
  360. }
  361. // 用户协议
  362. .agreement {
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. padding: 10px 0;
  367. .van-checkbox {
  368. margin-right: 5rpx;
  369. }
  370. text {
  371. color: $uni-color;
  372. }
  373. }
  374. // 下单
  375. .submit {
  376. position: fixed;
  377. bottom: 0;
  378. left: 0;
  379. width: 100%;
  380. height: 60px;
  381. background-color: #fff;
  382. display: flex;
  383. justify-content: space-between;
  384. align-items: center;
  385. .price {
  386. color: #F39637;
  387. padding: 0 20px;
  388. }
  389. .btn {
  390. background: $uni-color;
  391. color: white;
  392. width: 120px;
  393. height: 45px;
  394. border-radius: 23px;
  395. font-size: 16px;
  396. display: flex;
  397. justify-content: center;
  398. align-items: center;
  399. }
  400. }
  401. }
  402. }
  403. </style>