productDetails.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="page">
  3. <u-navbar
  4. v-if="pageStatus != 'platform'"
  5. title="商品详情"
  6. @rightClick="rightClick"
  7. :autoBack="true"
  8. >
  9. </u-navbar>
  10. <u-navbar
  11. v-if="pageStatus == 'platform'"
  12. title="true"
  13. @rightClick="rightClick"
  14. :autoBack="true"
  15. >
  16. <view slot="center" class="u-top">
  17. <view
  18. :class="{ 'goods-Detail': goodsOrDetail == 1 }"
  19. @click="switchTab(1)"
  20. >商品</view
  21. >
  22. <view
  23. :class="{ 'goods-Detail': goodsOrDetail == 2 }"
  24. @click="switchTab(2)"
  25. >详情</view
  26. >
  27. </view>
  28. </u-navbar>
  29. <!-- v-if="pageStatus != 'platform'" -->
  30. <view v-if="!downOrGrounding && pageStatus != 'platform'">
  31. <view class="top-fail" v-if="commodityDetail.final_status != 'unreview'">
  32. <image
  33. src="../../static/mine/332.png"
  34. class="fail-icon"
  35. mode=""
  36. ></image>
  37. <text v-if="commodityDetail.final_status == 'refuse'"
  38. >涉及敏感文字,您发布的商品审核未通过</text
  39. >
  40. <text v-else-if="!downOrGrounding"
  41. >该商品已下架,如有需要请重新上架</text
  42. >
  43. </view>
  44. <view class="fail" v-if="commodityDetail.final_status == 'unreview'">
  45. <image
  46. src="../../static/mine/333.png"
  47. class="fail-icon"
  48. mode=""
  49. ></image>
  50. <text>商品还在审核中,请耐心等待</text>
  51. </view>
  52. </view>
  53. <image class="goods-img" :src="commodityDetail.image" mode=""></image>
  54. <view class="title-price" style="">
  55. <view class="price" v-if="commodityDetail.discount_price">
  56. <text style="font-size: 20rpx">折扣价</text>
  57. <text style="font-size: 18rpx">¥</text>
  58. <text style="font-size: 36rpx; font-weight: 600">{{
  59. commodityDetail.discount_price.split(".")[0]
  60. }}</text
  61. >.
  62. <text style="font-size: 18rpx">{{
  63. commodityDetail.discount_price.split(".")[1]
  64. }}</text>
  65. <text
  66. style="
  67. font-size: 24rpx;
  68. color: #ccc;
  69. text-decoration-line: line-through;
  70. "
  71. >
  72. ¥{{ commodityDetail.price }}
  73. </text>
  74. </view>
  75. <view class="goods-title">
  76. {{ commodityDetail.name_cn }}
  77. </view>
  78. </view>
  79. <view class="goods-detail" id="product-detail"> 商品详情 </view>
  80. <view class="detail">
  81. <view class="u-content">
  82. <u-parse :content="commodityDetail.detail_cn"></u-parse>
  83. </view>
  84. </view>
  85. <view
  86. class="footer"
  87. v-if="
  88. (!downOrGrounding || pageStatus == 'platform') &&
  89. commodityDetail.final_status != 'unreview'
  90. "
  91. >
  92. <!-- <button class="btn">编辑商品</button> -->
  93. <button
  94. class="btn"
  95. v-if="pageStatus == 'platform'"
  96. @click="groundingProduct"
  97. >
  98. 上架商品
  99. </button>
  100. <button class="btn" v-else @click="groundingCommodity">上架商品</button>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. export default {
  106. data() {
  107. return {
  108. goodsId: 0,
  109. pageStatus: "", //判断商品是什么商品,平台库或其他
  110. commodityDetail: {}, //商品详情
  111. goodsOrDetail: 1,
  112. scrollTop: 0,
  113. };
  114. },
  115. onLoad(options) {
  116. this.goodsId = options.goodsId;
  117. this.pageStatus = options.pageStatus;
  118. if (options.pageStatus == "platform" || options.pageStatus == "supply") {
  119. this.getGoodsDetail();
  120. } else {
  121. this.getGoodsManageDetail();
  122. }
  123. },
  124. onPageScroll(e) {
  125. this.scrollTop = e.scrollTop;
  126. },
  127. computed: {
  128. downOrGrounding() {
  129. if (this.commodityDetail.status == "down") {
  130. return false;
  131. } else {
  132. if (this.commodityDetail.merchant_goods == "down") {
  133. return false;
  134. } else {
  135. return true;
  136. }
  137. }
  138. },
  139. },
  140. methods: {
  141. rightClick() {},
  142. //获取平台库商品详情
  143. getGoodsDetail() {
  144. uni.$u.http
  145. .get(`/api/goods/platform_goods_details/${this.goodsId}`)
  146. .then((res) => {
  147. this.commodityDetail = res;
  148. });
  149. },
  150. switchTab(num) {
  151. this.goodsOrDetail = num;
  152. if (num == 1) {
  153. //返回顶部
  154. uni.pageScrollTo({
  155. scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0
  156. duration: 300, // 滚动动画的时长
  157. });
  158. } else {
  159. uni
  160. .createSelectorQuery()
  161. .select("#product-detail")
  162. .boundingClientRect((data) => {
  163. //目标位置的节点:类class或者id
  164. uni
  165. .createSelectorQuery()
  166. .select(".page")
  167. .boundingClientRect((res) => {
  168. //最外层盒子的节点:类class或者id
  169. uni.pageScrollTo({
  170. duration: 100, //过渡时间
  171. scrollTop: data.top - res.top, //到达距离顶部的top值
  172. //scrollTop:data.top - res.top,//如果置顶
  173. });
  174. })
  175. .exec();
  176. })
  177. .exec();
  178. }
  179. },
  180. //获取商品管理商品详情
  181. getGoodsManageDetail() {
  182. uni.$u.http.get(`/api/goods/detail/${this.goodsId}`).then((res) => {
  183. this.commodityDetail = res;
  184. });
  185. },
  186. //上架平台库商品
  187. groundingProduct() {
  188. uni.$u.http
  189. .post(`/api/goods/elencazione`, {
  190. goods_id: this.commodityDetail.id,
  191. })
  192. .then((res) => {
  193. this.getGoodsDetail();
  194. uni.showToast({
  195. title: "已上架",
  196. icon: "none",
  197. });
  198. });
  199. },
  200. //上架商品
  201. groundingCommodity() {
  202. if (this.commodityDetail.status == "down") {
  203. uni.showToast({
  204. title: "商品已下架,无法上架",
  205. icon: "none",
  206. });
  207. return;
  208. }
  209. uni.$u.http
  210. .post(`/api/goods/elencazione`, {
  211. goods_id: this.commodityDetail.merchant_goods_id,
  212. })
  213. .then((res) => {
  214. if (this.pageStatus == "platform") {
  215. this.getGoodsDetail();
  216. } else {
  217. this.getGoodsManageDetail();
  218. }
  219. uni.showToast({
  220. title: "已上架",
  221. icon: "none",
  222. });
  223. });
  224. },
  225. },
  226. mounted() {
  227. // uni.setNavigationBarTitle({
  228. // title: "商品详情",
  229. // });
  230. },
  231. };
  232. </script>
  233. <style lang="scss" scoped>
  234. .page {
  235. //background-color: #fff;
  236. padding-bottom: 150rpx;
  237. margin-top: 174rpx;
  238. .u-top {
  239. display: flex;
  240. width: 200rpx;
  241. justify-content: space-between;
  242. .goods-Detail {
  243. color: #f83224;
  244. }
  245. }
  246. .top-fail {
  247. height: 60rpx;
  248. background-color: #fff1ee;
  249. padding-left: 24rpx;
  250. display: flex;
  251. align-items: center;
  252. font-size: 24rpx;
  253. color: #333;
  254. .fail-icon {
  255. width: 32rpx;
  256. height: 32rpx;
  257. margin-right: 10rpx;
  258. }
  259. }
  260. .fail {
  261. height: 60rpx;
  262. background-color: #fff1d7;
  263. padding-left: 24rpx;
  264. display: flex;
  265. align-items: center;
  266. font-size: 24rpx;
  267. color: #333;
  268. .fail-icon {
  269. width: 32rpx;
  270. height: 32rpx;
  271. margin-right: 10rpx;
  272. }
  273. }
  274. .goods-img {
  275. width: 100%;
  276. height: 750rpx;
  277. }
  278. .title-price {
  279. background-color: #fff;
  280. width: 96%;
  281. margin: 0 auto;
  282. border-radius: 16rpx;
  283. padding-bottom: 36rpx;
  284. margin-top: 20rpx;
  285. padding-top: 10rpx;
  286. }
  287. .price {
  288. color: #f83224;
  289. margin-top: 6rpx;
  290. padding-left: 40rpx;
  291. font-weight: 600;
  292. }
  293. .goods-title {
  294. padding: 0 40rpx;
  295. font-size: 32rpx;
  296. margin-top: 20rpx;
  297. }
  298. .goods-detail {
  299. font-size: 28rpx;
  300. padding-left: 40rpx;
  301. background-color: #fff;
  302. width: 90%;
  303. margin: 0 auto;
  304. margin-top: 40rpx;
  305. border-radius: 16rpx 16rpx 0 0;
  306. padding-top: 30rpx;
  307. }
  308. .detail {
  309. padding: 24rpx 20rpx;
  310. background-color: #fff;
  311. width: 90%;
  312. margin: 0 auto;
  313. border-radius: 0 0 16rpx 16rpx;
  314. .detail-img {
  315. width: 100%;
  316. }
  317. }
  318. .footer {
  319. position: fixed;
  320. bottom: 0;
  321. width: 100%;
  322. padding-bottom: 84rpx;
  323. padding-top: 20rpx;
  324. background-color: #fff;
  325. .btn {
  326. border-radius: 52rpx;
  327. background-color: #f83224;
  328. color: #fff;
  329. border: none;
  330. padding: 0;
  331. margin: 0;
  332. width: 94%;
  333. font-size: 30rpx;
  334. margin: 0 auto;
  335. }
  336. }
  337. }
  338. </style>