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

377 lines
8.1 KiB

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