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.

327 lines
7.2 KiB

11 months ago
  1. <template>
  2. <view class="productDetail">
  3. <view class="top-btn">
  4. <view class="" @click="goBack"><img src="/static/product/46646.png" alt="" /></view>
  5. <!-- <view class=""><img src="/static/product/46647.png" alt="" /></view> -->
  6. </view>
  7. <view class="swiper">
  8. <u-swiper :list="product.image" indicator indicatorMode="dot" circular height="65vh"
  9. :indicatorStyle="{bottom : '0px'}" indicatorActiveColor="#E01717"
  10. indicatorInactiveColor="#E2E2E2"></u-swiper>
  11. </view>
  12. <view class="content">
  13. <view class="title">
  14. {{ product.title }}
  15. </view>
  16. <view class="line-price">
  17. <text class="price">{{ product.price }}</text>
  18. <text class="oldPrice" v-if="product.oldPrice">{{ product.oldPrice }}</text>
  19. </view>
  20. <view class="const">
  21. <!-- <text>{{ $t('page.productDetail.Gross-sales') }}{{ product.payNum }}</text>
  22. <text>{{ $t('page.productDetail.inventory') }}{{ product.num }}</text> -->
  23. </view>
  24. <u-parse :content="product.shopDetails"></u-parse>
  25. </view>
  26. <view class="bottom-shop">
  27. <view class="left-shop">
  28. <view class="icon" @click="goHome">
  29. <u-icon name="home" size="25px" color="#E01717"></u-icon>
  30. <view class="">
  31. {{ $t('tabbar.title.1') }}
  32. </view>
  33. </view>
  34. <view class="icon">
  35. <u-icon name="heart" size="25px" v-if="!product.cel" @click="collect"></u-icon>
  36. <u-icon name="heart-fill" size="25px" v-else color="#E01717" @click="collect"></u-icon>
  37. <view class="">
  38. {{ $t('page.productDetail.collect') }}
  39. </view>
  40. </view>
  41. </view>
  42. <view class="right-shop">
  43. <view class="cart" @click="type = false;show = true">
  44. {{ $t('page.productDetail.Add-to-cart') }}
  45. </view>
  46. <view class="Buy" @click="type = true;show = true">
  47. {{ $t('page.productDetail.Buy-now') }}
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 购买 -->
  52. <u-popup :show="show" mode="bottom" @close="close" @open="open">
  53. <view class="shop-box">
  54. <view class="top-info">
  55. <view class="left-img">
  56. <img :src="product.image[0]" width="100%" alt="" />
  57. </view>
  58. <view class="right-text">
  59. <view class="title">
  60. {{ product.title }}
  61. </view>
  62. <view class="price">
  63. {{ product.price }}
  64. </view>
  65. </view>
  66. </view>
  67. <view class="const" style="margin: 0 20px;">
  68. <!-- <text>{{ $t('page.productDetail.Gross-sales') }}{{ product.payNum }}</text>
  69. <text>{{ $t('page.productDetail.inventory') }}{{ product.num }}</text> -->
  70. </view>
  71. <view class="number-box">
  72. <view class="">
  73. {{ type ? $t('page.productDetail.buy-quantity') : $t('page.productDetail.Add-cart-quantity' )}}
  74. </view>
  75. <u-number-box v-model="quantity" :min="1" :max="product.num" style="transform: scale(0.8);"
  76. @change="valChange"></u-number-box>
  77. </view>
  78. </view>
  79. <u-button :style="{'background-color': type ? '#EC534E' : '#F8AA48',color: '#fff'}"
  80. :text="type ? $t('page.productDetail.Buy-now') : $t('page.productDetail.Add-to-cart')"
  81. @click="submit"></u-button>
  82. </u-popup>
  83. </view>
  84. </template>
  85. <script>
  86. export default {
  87. data() {
  88. return {
  89. show: false,
  90. type: false,
  91. quantity: 1,
  92. product: {
  93. image: []
  94. }
  95. }
  96. },
  97. onShow() {
  98. this.getData()
  99. },
  100. methods: {
  101. collect(){
  102. this.request('collectionShop', {}, {
  103. shopId : this.product.id
  104. })
  105. .then(res => {
  106. if(res.code == 200){
  107. this.product.cel = !this.product.cel
  108. uni.$u.toast(this.$t('success-operation'))
  109. }
  110. })
  111. },
  112. getData() {
  113. this.request('getShopOne', {}, {
  114. "id": this.$route.query.id,
  115. token : localStorage.getItem('token')
  116. }).then(res => {
  117. res.result.image = res.result.image.split(',')
  118. this.product = res.result
  119. })
  120. },
  121. goBack() {
  122. uni.navigateBack({
  123. delta: 3
  124. })
  125. },
  126. goHome() {
  127. uni.switchTab({
  128. url: '/pages/home/home'
  129. })
  130. },
  131. close() {
  132. this.show = false
  133. },
  134. open() {},
  135. valChange() {},
  136. submit() {
  137. this.show = false
  138. if (this.type) {
  139. this.request("createOrder", {
  140. shopId: this.$route.query.id,
  141. num: this.quantity,
  142. price: this.product.price,
  143. image : this.product.image[0],
  144. title : this.product.title,
  145. subTitle : this.product.subTitle,
  146. }).then(res => {
  147. if (res.code === 200) {
  148. return uni.navigateTo({
  149. url: '/pages/productDetail/payOrder/payOrder?id='
  150. + res.result.id +
  151. '&quantity=' + this
  152. .quantity,
  153. })
  154. }
  155. })
  156. } else { //添加购物车
  157. this.request('saveCart', {
  158. shopId: this.$route.query.id,
  159. shopName: this.product.title,
  160. num: this.quantity,
  161. price: this.product.price,
  162. image: this.product.image[0],
  163. }).then(res => {
  164. if (res.code == 200) {
  165. this.$MyToast(this.$t('page.productDetail.Add-cart-success'), {
  166. title: this.$t('myToactTitle')
  167. })
  168. }
  169. })
  170. }
  171. }
  172. }
  173. }
  174. </script>
  175. <style scoped lang="scss">
  176. .productDetail {
  177. width: 100%;
  178. background-color: #fff;
  179. min-height: 100vh;
  180. .top-btn {
  181. position: absolute;
  182. top: 0;
  183. padding: 15px;
  184. display: flex;
  185. justify-content: space-between;
  186. z-index: 99999999;
  187. width: 100%;
  188. box-sizing: border-box;
  189. }
  190. .swiper {
  191. padding: 20px;
  192. }
  193. .content {
  194. padding: 0 20px;
  195. padding-bottom: 50px;
  196. .line-price {
  197. height: 90rpx;
  198. line-height: 90rpx;
  199. border-bottom: 1px solid #B8B8B8;
  200. .price {
  201. font-size: 49rpx;
  202. padding-right: 8px;
  203. color: #E01717;
  204. }
  205. .oldPrice {
  206. font-size: 28rpx;
  207. text-decoration: line-through;
  208. color: #B8B8B8;
  209. }
  210. }
  211. }
  212. .const {
  213. display: flex;
  214. justify-content: space-between;
  215. height: 10px;
  216. // height: 30px;
  217. // background-color: #F3F3F3;
  218. line-height: 30px;
  219. padding: 0 10px;
  220. color: #333333;
  221. // margin: 15px 0;
  222. font-size: 28rpx;
  223. }
  224. .bottom-shop {
  225. position: fixed;
  226. bottom: 0;
  227. left: 0;
  228. height: 50px;
  229. display: flex;
  230. width: 100%;
  231. background-color: #fff;
  232. .left-shop {
  233. flex: 2;
  234. display: flex;
  235. justify-content: space-around;
  236. box-sizing: border-box;
  237. align-items: center;
  238. .icon {
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: center;
  242. align-items: center;
  243. font-size: 11px;
  244. }
  245. }
  246. .right-shop {
  247. flex: 3;
  248. display: flex;
  249. color: #fff;
  250. font-size: 26rpx;
  251. .cart {
  252. width: 50%;
  253. height: 100%;
  254. background-color: #F8AA48;
  255. display: flex;
  256. justify-content: center;
  257. align-items: center;
  258. }
  259. .Buy {
  260. width: 50%;
  261. height: 100%;
  262. background-color: #EC534E;
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. }
  267. }
  268. }
  269. .shop-box {
  270. .top-info {
  271. display: flex;
  272. width: 100%;
  273. box-sizing: border-box;
  274. padding: 20px;
  275. .left-img {
  276. flex: 1;
  277. }
  278. .right-text {
  279. flex: 3;
  280. padding-left: 10px;
  281. .title {
  282. font-size: 28rpx;
  283. margin-bottom: 5px;
  284. }
  285. .price {
  286. font-size: 39rpx;
  287. padding-right: 8px;
  288. color: #E01717;
  289. }
  290. }
  291. }
  292. .number-box {
  293. display: flex;
  294. justify-content: space-between;
  295. height: 30px;
  296. line-height: 30px;
  297. padding: 0 10px;
  298. color: #333333;
  299. margin: 15px 0;
  300. font-size: 28rpx;
  301. }
  302. }
  303. }
  304. </style>