productDetails.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. pageStatus != 'supply'
  91. "
  92. >
  93. <!-- <button class="btn">编辑商品</button> -->
  94. <button
  95. class="btn"
  96. v-if="pageStatus == 'platform'"
  97. @click="groundingProduct"
  98. >
  99. 上架商品
  100. </button>
  101. <button class="btn" v-else @click="groundingCommodity">上架商品</button>
  102. </view>
  103. <view
  104. class="footer"
  105. v-if="
  106. pageStatus == 'supply' &&
  107. commodityDetail.final_status != 'unreview' &&
  108. commodityDetail.final_status != 'refuse'
  109. "
  110. >
  111. <button
  112. class="btn"
  113. v-if="commodityDetail.status == 'down'"
  114. @click="supplyChain('normal')"
  115. >
  116. 上架商品</button
  117. ><button
  118. class="btn"
  119. v-if="commodityDetail.status == 'normal'"
  120. @click="supplyChain('down')"
  121. >
  122. 下架商品
  123. </button></view
  124. >
  125. </view>
  126. </template>
  127. <script>
  128. export default {
  129. data() {
  130. return {
  131. goodsId: 0,
  132. pageStatus: "", //判断商品是什么商品,平台库或其他
  133. commodityDetail: {}, //商品详情
  134. goodsOrDetail: 1,
  135. scrollTop: 0,
  136. };
  137. },
  138. onLoad(options) {
  139. this.goodsId = options.goodsId;
  140. this.pageStatus = options.pageStatus;
  141. if (options.pageStatus == "platform" || options.pageStatus == "supply") {
  142. this.getGoodsDetail();
  143. } else {
  144. this.getGoodsManageDetail();
  145. }
  146. },
  147. onPageScroll(e) {
  148. this.scrollTop = e.scrollTop;
  149. },
  150. computed: {
  151. downOrGrounding() {
  152. //判断供应链商品是否存在审核失败
  153. if (
  154. this.pageStatus == "supply" &&
  155. this.commodityDetail.review_status == "2"
  156. ) {
  157. return false;
  158. }
  159. if (this.commodityDetail.status == "down") {
  160. if (
  161. this.pageStatus == "supply" &&
  162. this.commodityDetail.review_status == "2"
  163. ) {
  164. return false;
  165. }
  166. return false;
  167. } else {
  168. if (this.commodityDetail.merchant_goods == "down") {
  169. return false;
  170. } else {
  171. return true;
  172. }
  173. }
  174. },
  175. },
  176. methods: {
  177. rightClick() {},
  178. // 上架 or 下架 供应链商品
  179. supplyChain(status) {
  180. uni.$u.http
  181. .post(`/api/goods/supply_status`, {
  182. goods_id: this.commodityDetail.id,
  183. status,
  184. })
  185. .then((res) => {
  186. this.getGoodsDetail();
  187. uni.showToast({
  188. title: status == "down" ? "下架成功" : "上架成功",
  189. icon: "none",
  190. });
  191. });
  192. },
  193. //获取平台库商品详情
  194. getGoodsDetail() {
  195. uni.$u.http
  196. .get(`/api/goods/platform_goods_details/${this.goodsId}`)
  197. .then((res) => {
  198. this.commodityDetail = res;
  199. });
  200. },
  201. switchTab(num) {
  202. this.goodsOrDetail = num;
  203. if (num == 1) {
  204. //返回顶部
  205. uni.pageScrollTo({
  206. scrollTop: 0, // 滚动到页面的目标位置 这个是滚动到顶部, 0
  207. duration: 300, // 滚动动画的时长
  208. });
  209. } else {
  210. uni
  211. .createSelectorQuery()
  212. .select("#product-detail")
  213. .boundingClientRect((data) => {
  214. //目标位置的节点:类class或者id
  215. uni
  216. .createSelectorQuery()
  217. .select(".page")
  218. .boundingClientRect((res) => {
  219. //最外层盒子的节点:类class或者id
  220. uni.pageScrollTo({
  221. duration: 100, //过渡时间
  222. scrollTop: data.top - res.top, //到达距离顶部的top值
  223. //scrollTop:data.top - res.top,//如果置顶
  224. });
  225. })
  226. .exec();
  227. })
  228. .exec();
  229. }
  230. },
  231. //获取商品管理商品详情
  232. getGoodsManageDetail() {
  233. uni.$u.http.get(`/api/goods/detail/${this.goodsId}`).then((res) => {
  234. this.commodityDetail = res;
  235. });
  236. },
  237. //上架平台库商品
  238. groundingProduct() {
  239. uni.$u.http
  240. .post(`/api/goods/elencazione`, {
  241. goods_id: this.commodityDetail.id,
  242. })
  243. .then((res) => {
  244. this.getGoodsDetail();
  245. uni.showToast({
  246. title: "已上架",
  247. icon: "none",
  248. });
  249. });
  250. },
  251. //上架商品
  252. groundingCommodity() {
  253. if (this.commodityDetail.status == "down") {
  254. uni.showToast({
  255. title: "商品已下架,无法上架",
  256. icon: "none",
  257. });
  258. return;
  259. }
  260. uni.$u.http
  261. .post(`/api/goods/elencazione`, {
  262. goods_id: this.commodityDetail.merchant_goods_id,
  263. })
  264. .then((res) => {
  265. if (this.pageStatus == "platform") {
  266. this.getGoodsDetail();
  267. } else {
  268. this.getGoodsManageDetail();
  269. }
  270. uni.showToast({
  271. title: "已上架",
  272. icon: "none",
  273. });
  274. });
  275. },
  276. },
  277. mounted() {
  278. // uni.setNavigationBarTitle({
  279. // title: "商品详情",
  280. // });
  281. },
  282. };
  283. </script>
  284. <style lang="scss" scoped>
  285. .page {
  286. //background-color: #fff;
  287. padding-bottom: 150rpx;
  288. margin-top: 174rpx;
  289. .u-top {
  290. display: flex;
  291. width: 200rpx;
  292. justify-content: space-between;
  293. .goods-Detail {
  294. color: #f83224;
  295. }
  296. }
  297. .top-fail {
  298. height: 60rpx;
  299. background-color: #fff1ee;
  300. padding-left: 24rpx;
  301. display: flex;
  302. align-items: center;
  303. font-size: 24rpx;
  304. color: #333;
  305. .fail-icon {
  306. width: 32rpx;
  307. height: 32rpx;
  308. margin-right: 10rpx;
  309. }
  310. }
  311. .fail {
  312. height: 60rpx;
  313. background-color: #fff1d7;
  314. padding-left: 24rpx;
  315. display: flex;
  316. align-items: center;
  317. font-size: 24rpx;
  318. color: #333;
  319. .fail-icon {
  320. width: 32rpx;
  321. height: 32rpx;
  322. margin-right: 10rpx;
  323. }
  324. }
  325. .goods-img {
  326. width: 100%;
  327. height: 750rpx;
  328. }
  329. .title-price {
  330. background-color: #fff;
  331. width: 96%;
  332. margin: 0 auto;
  333. border-radius: 16rpx;
  334. padding-bottom: 36rpx;
  335. margin-top: 20rpx;
  336. padding-top: 10rpx;
  337. }
  338. .price {
  339. color: #f83224;
  340. margin-top: 6rpx;
  341. padding-left: 40rpx;
  342. font-weight: 600;
  343. }
  344. .goods-title {
  345. padding: 0 40rpx;
  346. font-size: 32rpx;
  347. margin-top: 20rpx;
  348. }
  349. .goods-detail {
  350. font-size: 28rpx;
  351. padding-left: 40rpx;
  352. background-color: #fff;
  353. width: 90%;
  354. margin: 0 auto;
  355. margin-top: 40rpx;
  356. border-radius: 16rpx 16rpx 0 0;
  357. padding-top: 30rpx;
  358. }
  359. .detail {
  360. padding: 24rpx 20rpx;
  361. background-color: #fff;
  362. width: 90%;
  363. margin: 0 auto;
  364. border-radius: 0 0 16rpx 16rpx;
  365. .detail-img {
  366. width: 100%;
  367. }
  368. }
  369. .footer {
  370. position: fixed;
  371. bottom: 0;
  372. width: 100%;
  373. padding-bottom: 84rpx;
  374. padding-top: 20rpx;
  375. background-color: #fff;
  376. .btn {
  377. border-radius: 52rpx;
  378. background-color: #f83224;
  379. color: #fff;
  380. border: none;
  381. padding: 0;
  382. margin: 0;
  383. width: 94%;
  384. font-size: 30rpx;
  385. margin: 0 auto;
  386. }
  387. }
  388. }
  389. </style>