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

310 lines
6.2 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
1 month ago
5 months ago
5 months ago
5 months ago
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 month ago
5 months ago
5 months ago
5 months ago
3 months ago
1 month ago
3 months ago
1 month ago
3 months ago
1 month ago
5 months ago
5 months ago
2 weeks 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
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" bgColor="#019245" color="#fff" />
  5. <view class="swipe">
  6. <uv-swiper :list="productDetail.image
  7. && productDetail.image.split(',')" @change="e => current1 = e.current" indicator height="650rpx">
  8. <!-- 指示器 -->
  9. <template v-slot:indicator>
  10. <view class="indicator">
  11. <view class="indicator__dot" v-for="(item, index) in productDetail.image
  12. && productDetail.image.split(',')" :key="index" :class="[index === current1 && 'indicator__dot--active']">
  13. </view>
  14. </view>
  15. </template>
  16. </uv-swiper>
  17. </view>
  18. <!-- 商品标题 -->
  19. <view class="info">
  20. <view class="new-price">
  21. <text></text><text :style="{fontSize:'50rpx'}">{{ productDetail.price }}</text>
  22. </view>
  23. <view class="title">
  24. {{ productDetail.title }}
  25. </view>
  26. </view>
  27. <!-- 参数 -->
  28. <view v-if="productDetail.sku" class="params">
  29. <view class="params-main">
  30. <view class="title">参数</view>
  31. <view class="descript">
  32. {{ productDetail.sku }}
  33. </view>
  34. </view>
  35. <view class="server-arraw">
  36. <uv-icon name="arrow-right"></uv-icon>
  37. </view>
  38. </view>
  39. <!-- 商品详情 -->
  40. <view class="item-line">
  41. <!-- <view class="before"></view> -->
  42. <view class="label">商品详情</view>
  43. </view>
  44. <uv-parse :content="productDetail.details" />
  45. <!-- 分享和购买按钮 -->
  46. <submit @service="service" @toSend="toSend" @submit="submit" @addCart="addCart" :detail="productDetail" />
  47. <!-- 联系客服 -->
  48. <customerServicePopup ref="customerServicePopup" />
  49. <placeOrder ref="placeOrder" :item="productDetail" @addCart="addCart" />
  50. <uv-safe-bottom />
  51. </view>
  52. </template>
  53. <script>
  54. import submit from '../components/product/submit.vue'
  55. import submitUnitSelect from '../components/product/submitUnitSelect.vue'
  56. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  57. import placeOrder from '../components/order/placeOrder.vue'
  58. import { mapMutations } from 'vuex'
  59. export default {
  60. components: {
  61. submit,
  62. submitUnitSelect,
  63. customerServicePopup,
  64. placeOrder
  65. },
  66. data() {
  67. return {
  68. productDetail: {
  69. image: '',
  70. details: '',
  71. },
  72. id: 0,
  73. current1: 0
  74. }
  75. },
  76. onLoad(args) {
  77. this.id = args.id
  78. this.getGoodsDetail()
  79. if (args.open === 'true') this.submit()
  80. },
  81. onShow() {
  82. },
  83. methods: {
  84. ...mapMutations( 'cartNum' , ['incrementProduct'] ),
  85. // 分享商品
  86. share() {
  87. },
  88. // 加入购物车
  89. addCart(){
  90. this.incrementProduct({ productId: this.id })
  91. uni.showLoading({
  92. title: '加载中...'
  93. })
  94. this.$api('addShopcar', {
  95. goodsId: this.id,
  96. num: 1,
  97. }, res => {
  98. uni.hideLoading()
  99. if (res.code == 200) {
  100. uni.showToast({
  101. title: '加入购物车成功',
  102. icon: 'success',
  103. duration: 1000
  104. })
  105. }
  106. })
  107. },
  108. // 立即下单
  109. submit() {
  110. // 如果还没有登录,则先登录
  111. if (!uni.getStorageSync('token')) {
  112. this.$utils.navigateTo('/pages_order/auth/wxLogin')
  113. return
  114. }
  115. this.$refs.placeOrder.open()
  116. },
  117. toSend(){
  118. this.$store.commit('setPayOrderProduct', [
  119. this.productDetail
  120. ])
  121. // this.$utils.navigateTo('/pages_order/order/receiveGift?id=1894006757315850241')
  122. this.$utils.navigateTo('/pages_order/order/createOrder?type=give')
  123. },
  124. // 获取商品
  125. getGoodsDetail() {
  126. uni.showLoading({
  127. title: '加载中...'
  128. })
  129. this.$api('queryGoodsById', {
  130. id: this.id
  131. }, res => {
  132. uni.hideLoading()
  133. if (res.code == 200) {
  134. this.productDetail = res.result
  135. }
  136. })
  137. },
  138. // 联系客服
  139. service() {
  140. this.$refs.customerServicePopup.open()
  141. },
  142. }
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. .page {
  147. padding-bottom: 120rpx;
  148. .leftClick{
  149. position: absolute;
  150. top: calc(var(--status-bar-height) + 20rpx);
  151. left: 20rpx;
  152. background-color: #00000073;
  153. padding: 20rpx;
  154. border-radius: 50%;
  155. z-index: 99;
  156. }
  157. .swipe {
  158. // 这是轮播图的指示器自定义样式
  159. @mixin flex($direction: row) {
  160. /* #ifndef APP-NVUE */
  161. display: flex;
  162. /* #endif */
  163. flex-direction: $direction;
  164. }
  165. .indicator {
  166. @include flex(row);
  167. justify-content: center;
  168. &__dot {
  169. height: 8px;
  170. width: 8px;
  171. border-radius: 100%;
  172. background-color: #fff;
  173. margin: 0 5px;
  174. transition: background-color 0.3s;
  175. &--active {
  176. background-color: $uni-color;
  177. }
  178. }
  179. }
  180. }
  181. // 商品标题
  182. .info {
  183. padding: 20rpx;
  184. padding-left: 30rpx;
  185. background-color: #fff;
  186. display: flex;
  187. flex-direction: column;
  188. gap: 14rpx;
  189. border-bottom: 30rpx #F7F7F7 solid;
  190. .new-price{
  191. color: $uni-color-second;
  192. }
  193. .title {
  194. font-size: 30rpx;
  195. font-weight: 600;
  196. }
  197. }
  198. // 服务 & 参数
  199. .server,
  200. .params {
  201. background: white;
  202. display: flex;
  203. justify-content: space-between;
  204. flex-wrap: wrap;
  205. padding: 30rpx 20rpx;
  206. box-sizing: border-box;
  207. .setver-main,
  208. .params-main {
  209. display: flex;
  210. flex-wrap: wrap;
  211. width: 90%;
  212. font-size: 32rpx;
  213. .title {
  214. color: #7C7C7C;
  215. margin-right: 20rpx;
  216. }
  217. }
  218. .server-arraw {
  219. display: flex;
  220. justify-content: flex-end;
  221. text-align: right;
  222. }
  223. }
  224. // 价格
  225. .price {
  226. display: flex;
  227. align-items: center;
  228. color: #f40;
  229. font-size: 30rpx;
  230. align-items: flex-end;
  231. .money {
  232. font-size: 30rpx;
  233. .unit {
  234. font-size: 24rpx;
  235. }
  236. }
  237. .price-imgs {
  238. display: flex;
  239. flex-wrap: wrap;
  240. .price-img {
  241. width: 80rpx;
  242. height: 30rpx;
  243. margin-left: 10rpx;
  244. }
  245. }
  246. }
  247. .oldPrice{
  248. color: #999;
  249. font-size: 24rpx;
  250. text-decoration: line-through;
  251. }
  252. // 商品详情
  253. .item-line {
  254. display: flex;
  255. background: white;
  256. box-sizing: border-box;
  257. font-size: 34rpx;
  258. padding: 20rpx;
  259. }
  260. .item-line .before {
  261. content: "";
  262. width: 8rpx;
  263. height: 30rpx;
  264. background: $uni-color;
  265. border-radius: 4rpx;
  266. margin-right: 10rpx;
  267. margin-top: 15rpx;
  268. }
  269. .item-line .label {
  270. display: flex;
  271. align-items: center;
  272. width: 152rpx;
  273. height: 60rpx;
  274. }
  275. }
  276. </style>