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

367 lines
7.3 KiB

5 months ago
5 months ago
3 months ago
3 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
3 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
3 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
3 months ago
3 months ago
3 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
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
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <!-- <navbar title="商品详情" leftClick @leftClick="$utils.navigateBack" /> -->
  5. <view class="leftClick"
  6. @click="$utils.navigateBack">
  7. <uv-icon
  8. size="30rpx"
  9. color="#fff"
  10. name="arrow-left"></uv-icon>
  11. </view>
  12. <view class="swipe">
  13. <uv-swiper :list="productDetail.image
  14. && productDetail.image.split(',')" indicator height="750rpx"></uv-swiper>
  15. </view>
  16. <!-- 商品标题 -->
  17. <view class="info">
  18. <view class="title">
  19. {{ productDetail.title }}
  20. </view>
  21. <view class="price">
  22. <view class="money">
  23. <text>{{ productDetail.price }}</text>
  24. <text class="unit">/元每件</text>
  25. </view>
  26. <view class="oldPrice">
  27. <text>{{ productDetail.oldPrice }}</text>
  28. <text class="unit">/</text>
  29. </view>
  30. </view>
  31. <view class="price">
  32. <view class="money">
  33. <text>{{ productDetail.goldPrice }}</text>
  34. <text class="unit">/元每件</text>
  35. </view>
  36. <view class="price-imgs">
  37. <image :src="configList.vip_money_one" mode="aspectFill"
  38. class="price-img"></image>
  39. </view>
  40. </view>
  41. <view class="price">
  42. <view class="money">
  43. <text>{{ productDetail.silverPrice }}</text>
  44. <text class="unit">/元每件</text>
  45. </view>
  46. <view class="price-imgs">
  47. <image :src="configList.vip_money_two" mode="aspectFill" class="price-img">
  48. </image>
  49. </view>
  50. </view>
  51. <view class="price">
  52. <view class="money">
  53. <text>{{ productDetail.diamondPrice }}</text>
  54. <text class="unit">/元每件</text>
  55. </view>
  56. <view class="price-imgs">
  57. <image :src="configList.vip_money_three" mode="aspectFill" class="price-img">
  58. </image>
  59. </view>
  60. </view>
  61. <!-- 库存信息 -->
  62. <view class="stock-info">
  63. <text>库存: {{ productDetail.num }}</text>
  64. <text v-if="productDetail.num <= 0" class="stock-warning">库存不足</text>
  65. </view>
  66. </view>
  67. <!-- 服务 -->
  68. <view class="server">
  69. <view class="setver-main">
  70. <view class="title">服务</view>
  71. <view class="descript">
  72. 免费上门退·7天无理由退货·快递发货
  73. </view>
  74. </view>
  75. <view class="server-arraw">
  76. <uv-icon name="arrow-right"></uv-icon>
  77. </view>
  78. </view>
  79. <!-- 参数 -->
  80. <view v-if="productDetail.sku" class="params">
  81. <view class="params-main">
  82. <view class="title">参数</view>
  83. <view class="descript">
  84. {{ productDetail.sku }}
  85. </view>
  86. </view>
  87. <view class="server-arraw">
  88. <uv-icon name="arrow-right"></uv-icon>
  89. </view>
  90. </view>
  91. <!-- 商品详情 -->
  92. <view class="item-line">
  93. <view class="before"></view>
  94. <view class="label">商品详情</view>
  95. </view>
  96. <uv-parse :content="productDetail.details"></uv-parse>
  97. <!-- 分享和购买按钮 -->
  98. <submit
  99. @service="service"
  100. @toSend="toSend"
  101. @submit="submit"
  102. @addCart="addCart"
  103. :detail="productDetail"
  104. :disabled="productDetail.num <= 0" />
  105. <!-- 联系客服 -->
  106. <customerServicePopup ref="customerServicePopup" />
  107. </view>
  108. </template>
  109. <script>
  110. import submit from '../components/product/submit.vue'
  111. import submitUnitSelect from '../components/product/submitUnitSelect.vue'
  112. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  113. export default {
  114. components: {
  115. submit,
  116. submitUnitSelect,
  117. customerServicePopup
  118. },
  119. data() {
  120. return {
  121. productDetail: {
  122. image: '',
  123. details: '',
  124. },
  125. id: 0,
  126. }
  127. },
  128. onLoad(args) {
  129. this.id = args.id
  130. },
  131. onShow() {
  132. this.getRiceProductDetail()
  133. },
  134. methods: {
  135. // 分享商品
  136. share() {
  137. },
  138. // 加入购物车
  139. addCart(){
  140. // 检查库存
  141. if(this.productDetail.num <= 0) {
  142. uni.showToast({
  143. title: '库存不足,无法加入购物车',
  144. icon: 'none'
  145. });
  146. return;
  147. }
  148. this.$api('addCart', {
  149. shopId : this.id,
  150. num : 1,
  151. }, res => {
  152. if(res.code == 200){
  153. uni.showToast({
  154. title: '加入购物车成功',
  155. icon: 'none'
  156. })
  157. }
  158. })
  159. },
  160. // 立即下单
  161. submit() {
  162. // 检查库存
  163. if(this.productDetail.num <= 0) {
  164. uni.showToast({
  165. title: '库存不足,无法下单',
  166. icon: 'none'
  167. });
  168. return;
  169. }
  170. this.$store.commit('setPayOrderProduct', [
  171. this.productDetail
  172. ])
  173. this.$utils.navigateTo('/pages_order/order/createOrder')
  174. },
  175. toSend(){
  176. // 检查库存
  177. if(this.productDetail.num <= 0) {
  178. uni.showToast({
  179. title: '库存不足,无法赠送',
  180. icon: 'none'
  181. });
  182. return;
  183. }
  184. this.$store.commit('setPayOrderProduct', [
  185. this.productDetail
  186. ])
  187. // this.$utils.navigateTo('/pages_order/order/receiveGift?id=1894006757315850241')
  188. this.$utils.navigateTo('/pages_order/order/createOrder?type=give')
  189. },
  190. // 获取商品
  191. getRiceProductDetail() {
  192. this.$api('getRiceProductDetail', {
  193. id: this.id
  194. }, res => {
  195. if (res.code == 200) {
  196. // 保留API返回的真实库存值,不再强制设置为1
  197. // 如果API没有返回库存,则默认为0
  198. if(res.result.num === undefined) {
  199. res.result.num = 0;
  200. }
  201. this.productDetail = res.result
  202. }
  203. })
  204. },
  205. // 联系客服
  206. service() {
  207. this.$refs.customerServicePopup.open()
  208. },
  209. }
  210. }
  211. </script>
  212. <style scoped lang="scss">
  213. .page {
  214. padding-bottom: 120rpx;
  215. .leftClick{
  216. position: absolute;
  217. top: calc(var(--status-bar-height) + 20rpx);
  218. left: 20rpx;
  219. background-color: #00000073;
  220. padding: 20rpx;
  221. border-radius: 50%;
  222. z-index: 99;
  223. }
  224. .swipe {}
  225. // 商品标题
  226. .info {
  227. padding: 20rpx;
  228. background-color: #fff;
  229. display: flex;
  230. flex-direction: column;
  231. gap: 14rpx;
  232. .title {
  233. font-size: 36rpx;
  234. font-weight: 900;
  235. }
  236. }
  237. // 服务 & 参数
  238. .server,
  239. .params {
  240. background: white;
  241. display: flex;
  242. justify-content: space-between;
  243. flex-wrap: wrap;
  244. padding: 30rpx 20rpx;
  245. box-sizing: border-box;
  246. .setver-main,
  247. .params-main {
  248. display: flex;
  249. flex-wrap: wrap;
  250. width: 90%;
  251. font-size: 32rpx;
  252. .title {
  253. color: #7C7C7C;
  254. margin-right: 20rpx;
  255. }
  256. }
  257. .server-arraw {
  258. display: flex;
  259. justify-content: flex-end;
  260. text-align: right;
  261. }
  262. }
  263. // 价格
  264. .price {
  265. display: flex;
  266. align-items: center;
  267. color: #f40;
  268. font-size: 30rpx;
  269. align-items: flex-end;
  270. .money {
  271. font-size: 30rpx;
  272. .unit {
  273. font-size: 24rpx;
  274. }
  275. }
  276. .price-imgs {
  277. display: flex;
  278. flex-wrap: wrap;
  279. .price-img {
  280. width: 80rpx;
  281. height: 30rpx;
  282. margin-left: 10rpx;
  283. }
  284. }
  285. }
  286. .stock-info {
  287. display: flex;
  288. align-items: center;
  289. justify-content: space-between;
  290. padding: 10rpx 0;
  291. font-size: 28rpx;
  292. color: #666;
  293. .stock-warning {
  294. color: #ff0000;
  295. font-weight: bold;
  296. }
  297. }
  298. .oldPrice{
  299. color: #999;
  300. font-size: 24rpx;
  301. text-decoration: line-through;
  302. }
  303. // 商品详情
  304. .item-line {
  305. display: flex;
  306. background: white;
  307. box-sizing: border-box;
  308. font-size: 34rpx;
  309. padding: 20rpx;
  310. }
  311. .item-line .before {
  312. content: "";
  313. width: 8rpx;
  314. height: 30rpx;
  315. background: $uni-color;
  316. border-radius: 4rpx;
  317. margin-right: 10rpx;
  318. margin-top: 15rpx;
  319. }
  320. .item-line .label {
  321. display: flex;
  322. align-items: center;
  323. width: 152rpx;
  324. height: 60rpx;
  325. }
  326. }
  327. </style>