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

370 lines
7.8 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
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. export default {
  119. components: {
  120. submit,
  121. submitUnitSelect,
  122. customerServicePopup,
  123. newCouponPopup,
  124. placeOrder
  125. },
  126. data() {
  127. return {
  128. productDetail: {
  129. image: '',
  130. details: '',
  131. },
  132. id: 0,
  133. current1: 0
  134. }
  135. },
  136. onLoad(args) {
  137. this.id = args.id
  138. this.getGoodsDetail()
  139. if (args.open === 'true') this.submit()
  140. },
  141. onShow() {
  142. },
  143. methods: {
  144. // 分享商品
  145. share() {
  146. },
  147. // 加入购物车
  148. addCart(){
  149. uni.showLoading({
  150. title: '加载中...'
  151. })
  152. this.$api('addShopcar', {
  153. goodsId: this.id,
  154. num: 1,
  155. }, res => {
  156. uni.hideLoading()
  157. if (res.code == 200) {
  158. uni.showToast({
  159. title: '加入购物车成功',
  160. icon: 'success',
  161. duration: 1000
  162. })
  163. }
  164. })
  165. },
  166. // 立即下单
  167. submit() {
  168. this.$refs.placeOrder.open()
  169. // this.$store.commit('setPayOrderProduct', [
  170. // this.productDetail
  171. // ])
  172. // this.$utils.navigateTo('/pages_order/order/createOrder')
  173. },
  174. toSend(){
  175. this.$store.commit('setPayOrderProduct', [
  176. this.productDetail
  177. ])
  178. // this.$utils.navigateTo('/pages_order/order/receiveGift?id=1894006757315850241')
  179. this.$utils.navigateTo('/pages_order/order/createOrder?type=give')
  180. },
  181. // 获取商品
  182. getGoodsDetail() {
  183. uni.showLoading({
  184. title: '加载中...'
  185. })
  186. this.$api('queryGoodsById', {
  187. id: this.id
  188. }, res => {
  189. uni.hideLoading()
  190. if (res.code == 200) {
  191. this.productDetail = res.result
  192. }
  193. })
  194. },
  195. // 联系客服
  196. service() {
  197. this.$refs.customerServicePopup.open()
  198. },
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .page {
  204. padding-bottom: 120rpx;
  205. .leftClick{
  206. position: absolute;
  207. top: calc(var(--status-bar-height) + 20rpx);
  208. left: 20rpx;
  209. background-color: #00000073;
  210. padding: 20rpx;
  211. border-radius: 50%;
  212. z-index: 99;
  213. }
  214. .swipe {
  215. // 这是轮播图的指示器自定义样式
  216. @mixin flex($direction: row) {
  217. /* #ifndef APP-NVUE */
  218. display: flex;
  219. /* #endif */
  220. flex-direction: $direction;
  221. }
  222. .indicator {
  223. @include flex(row);
  224. justify-content: center;
  225. &__dot {
  226. height: 8px;
  227. width: 8px;
  228. border-radius: 100%;
  229. background-color: #fff;
  230. margin: 0 5px;
  231. transition: background-color 0.3s;
  232. &--active {
  233. background-color: $uni-color;
  234. }
  235. }
  236. }
  237. }
  238. // 商品标题
  239. .info {
  240. padding: 20rpx;
  241. padding-left: 30rpx;
  242. background-color: #fff;
  243. display: flex;
  244. flex-direction: column;
  245. gap: 14rpx;
  246. border-bottom: 30rpx #F7F7F7 solid;
  247. .new-price{
  248. color: $uni-color-second;
  249. }
  250. .title {
  251. font-size: 30rpx;
  252. font-weight: 600;
  253. }
  254. }
  255. // 服务 & 参数
  256. .server,
  257. .params {
  258. background: white;
  259. display: flex;
  260. justify-content: space-between;
  261. flex-wrap: wrap;
  262. padding: 30rpx 20rpx;
  263. box-sizing: border-box;
  264. .setver-main,
  265. .params-main {
  266. display: flex;
  267. flex-wrap: wrap;
  268. width: 90%;
  269. font-size: 32rpx;
  270. .title {
  271. color: #7C7C7C;
  272. margin-right: 20rpx;
  273. }
  274. }
  275. .server-arraw {
  276. display: flex;
  277. justify-content: flex-end;
  278. text-align: right;
  279. }
  280. }
  281. // 价格
  282. .price {
  283. display: flex;
  284. align-items: center;
  285. color: #f40;
  286. font-size: 30rpx;
  287. align-items: flex-end;
  288. .money {
  289. font-size: 30rpx;
  290. .unit {
  291. font-size: 24rpx;
  292. }
  293. }
  294. .price-imgs {
  295. display: flex;
  296. flex-wrap: wrap;
  297. .price-img {
  298. width: 80rpx;
  299. height: 30rpx;
  300. margin-left: 10rpx;
  301. }
  302. }
  303. }
  304. .oldPrice{
  305. color: #999;
  306. font-size: 24rpx;
  307. text-decoration: line-through;
  308. }
  309. // 商品详情
  310. .item-line {
  311. display: flex;
  312. background: white;
  313. box-sizing: border-box;
  314. font-size: 34rpx;
  315. padding: 20rpx;
  316. }
  317. .item-line .before {
  318. content: "";
  319. width: 8rpx;
  320. height: 30rpx;
  321. background: $uni-color;
  322. border-radius: 4rpx;
  323. margin-right: 10rpx;
  324. margin-top: 15rpx;
  325. }
  326. .item-line .label {
  327. display: flex;
  328. align-items: center;
  329. width: 152rpx;
  330. height: 60rpx;
  331. }
  332. }
  333. </style>