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

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