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

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