detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view>
  3. <swiper class="swiper">
  4. <swiper-item v-for="item in files" :key="item.attachmentid">
  5. <u--image :src="item.cover" :lazy-load="true" width="100vw" :height="tovw(377)"
  6. @click.stop="previewImg(item.url)">
  7. <template v-slot:loading>
  8. <u-loading-icon color="red" />
  9. </template>
  10. </u--image>
  11. </swiper-item>
  12. </swiper>
  13. <view class="head">
  14. <view class="name u-line-1">{{ detail.name || '--' }}</view>
  15. <view class="tag u-line-1">
  16. {{ detail.tag }}
  17. </view>
  18. <view v-if="detail.pricetype == '一口价'" class="price-box">
  19. <text class="label">
  20. 价格
  21. </text>
  22. <text class="unit">
  23. </text>
  24. <text class="price">
  25. {{ CNY(detail.price, '') }}
  26. </text>
  27. <text class="unit">
  28. 元/{{ detail.unitname }}
  29. </text>
  30. </view>
  31. <block v-else>
  32. <view class="price-box">
  33. <text class="label">
  34. 总部返利价
  35. </text>
  36. <text class="unit">
  37. </text>
  38. <text class="price">
  39. {{ CNY(detail.price_rebate, '') }}
  40. </text>
  41. <text class="unit">
  42. 元/{{ detail.unitname }}
  43. </text>
  44. </view>
  45. <view class="price-box">
  46. <text class="label">
  47. 门店价
  48. </text>
  49. <text class="unit">
  50. </text>
  51. <text class="price">
  52. {{ CNY(detail.price_store, '') }}
  53. </text>
  54. <text class="unit">
  55. 元/{{ detail.unitname }}
  56. </text>
  57. <text class="delete">
  58. 原价:{{ CNY(detail.price_original) }} 元/{{ detail.unitname }}
  59. </text>
  60. </view>
  61. <view class="price-box">
  62. <text class="label">
  63. 定金
  64. </text>
  65. <text class="unit">
  66. </text>
  67. <text class="price">
  68. {{ CNY(detail.price_deposit, '') }}
  69. </text>
  70. <text class="unit">
  71. 元/{{ detail.unitname }}
  72. </text>
  73. </view>
  74. </block>
  75. <view style="height: 10px;" />
  76. <view class="row">
  77. 型号:{{ detail.model || '--' }}
  78. </view>
  79. <view v-if="detail.subtitle" class="row">
  80. {{ detail.subtitle }}
  81. </view>
  82. <view class="collect" hover-class="navigator-hover"
  83. @click="collectLoading ? '' : handleCollect(detail.iscollect)">
  84. <u-loading-icon v-if="collectLoading" size="20" />
  85. <block v-else>
  86. <text v-if="detail.iscollect == 0" class="iconfont icon-weishoucang" />
  87. <text v-else class="iconfont icon-yishoucang" style="color: #FFC300;" />
  88. 收藏
  89. </block>
  90. </view>
  91. </view>
  92. <storeInfo marTop="10" />
  93. <view class="division">
  94. <view class="line" />
  95. 详情
  96. <view class="line" />
  97. </view>
  98. <view v-if="detail.content" style="background-color: #fff;">
  99. <u-parse :content="detail.content" />
  100. </view>
  101. <u--image src="https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405081715135815557B4db50f9.webp"
  102. :lazy-load="true" width="100vw" height="none" mode="widthFix"
  103. @click.stop="previewImg('https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405081715135815557B4db50f9.webp')">
  104. <template v-slot:loading>
  105. <u-loading-icon color="red" />
  106. </template>
  107. </u--image>
  108. <view style="width: 100vw;height: 75px;background-color: #fff;" />
  109. <view class="footer">
  110. <view class="fun-but" @click="toHome" hover-class="navigator-hover">
  111. <view class="iconfont icon-a-biaoqianlanshouyexuanzhong" />
  112. <view class="text">
  113. 首页
  114. </view>
  115. </view>
  116. <view class="fun-but" hover-class="navigator-hover">
  117. <contact>
  118. <view class="iconfont icon-kefu" />
  119. <view class="text">
  120. 咨询
  121. </view>
  122. </contact>
  123. </view>
  124. <view class="fun-but" v-if="phoneNumber" hover-class="navigator-hover" @click="callPhone(phoneNumber)">
  125. <view class="iconfont icon-dianhua" />
  126. <view class="text">
  127. 致电
  128. </view>
  129. </view>
  130. <view class="place-an-order" @click="purchase" hover-class="navigator-hover">
  131. 预约购买
  132. </view>
  133. </view>
  134. </view>
  135. </template>
  136. <script>
  137. import { viewImage, formattedFiles } from "../../utils/settleFiles"
  138. import contact from "../../components/contact"
  139. export default {
  140. components: { contact },
  141. data() {
  142. return {
  143. detail: {
  144. sa_fadid: 0
  145. },
  146. files: [],
  147. collectLoading: false,
  148. phoneNumber: uni.getStorageSync("shop").phonenumber || ''
  149. }
  150. },
  151. onLoad(options) {
  152. this.detail.sa_fadid = options.id;
  153. this.getDetail()
  154. },
  155. methods: {
  156. toHome() {
  157. if (this.$Http.changePage) {
  158. this.$Http.changePage("index", '首页')
  159. uni.navigateBack();
  160. } else {
  161. uni.redirectTo({
  162. url: '/pages/index/index',
  163. })
  164. }
  165. },
  166. getDetail() {
  167. this.$Http.basic({
  168. "id": "20240428154202",
  169. "content": {
  170. "sa_fadid": this.detail.sa_fadid
  171. }
  172. }).then(res => {
  173. console.log("商品详情", res)
  174. if (this.cutoff(res.msg)) return;
  175. this.files = formattedFiles(res.data.attinfos_pic.map(v => v.attinfos[0])).map((v, i) => {
  176. if (v.fileType == 'image') v.cover = this.getSpecifiedImage(v, 'compressed')
  177. if (i == 0) res.data.cover = v.cover;
  178. return v
  179. })
  180. this.detail = res.data;
  181. uni.setNavigationBarTitle({
  182. title: res.data.name || '商品详情'
  183. });
  184. })
  185. },
  186. previewImg(url) {
  187. viewImage(url)
  188. },
  189. handleCollect(iscollect) {
  190. this.collectLoading = true;
  191. this.$Http.basic({
  192. "id": 20240416133702,
  193. "content": {
  194. "ownertable": "sa_fad",
  195. "ownerid": this.detail.sa_fadid,
  196. "type": 1
  197. },
  198. }).then(res => {
  199. console.log("收藏", res)
  200. this.collectLoading = false;
  201. if (this.cutoff(res.msg)) return;
  202. this.detail.iscollect = iscollect ? 0 : 1
  203. })
  204. },
  205. purchase() {
  206. uni.navigateTo({
  207. url: '/store/orderForm/insert?data=' + JSON.stringify(this.detail),
  208. })
  209. }
  210. },
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .swiper {
  215. width: 100vw;
  216. height: 377px;
  217. }
  218. .head {
  219. position: relative;
  220. background: #fff;
  221. padding: 10px;
  222. box-sizing: border-box;
  223. .name {
  224. width: 280px;
  225. height: 24px;
  226. line-height: 24px;
  227. font-family: Source Han Sans SC, Source Han Sans SC;
  228. font-weight: bold;
  229. font-size: 16px;
  230. color: #333333;
  231. }
  232. .tag {
  233. width: max-content;
  234. background: #FFFFFF;
  235. border: 1px solid #E3041F;
  236. padding: 2px 4px;
  237. box-sizing: border-box;
  238. font-family: PingFang SC, PingFang SC;
  239. font-size: 10px;
  240. color: #E3041F;
  241. margin-top: 5px;
  242. max-width: 355px;
  243. }
  244. .price-box {
  245. font-family: Source Han Sans SC, Source Han Sans SC;
  246. .label {
  247. color: #333;
  248. font-size: 12px;
  249. }
  250. .unit {
  251. font-family: Source Han Sans SC, Source Han Sans SC;
  252. font-size: 12px;
  253. color: #E3041F;
  254. margin-left: 4px;
  255. }
  256. .price {
  257. color: #E3041F;
  258. font-size: 18px;
  259. font-weight: bold;
  260. }
  261. .delete {
  262. font-family: Source Han Sans SC, Source Han Sans SC;
  263. font-size: 12px;
  264. color: #333333;
  265. text-decoration-line: line-through;
  266. margin-left: 10px;
  267. }
  268. }
  269. .price-box:last-child {
  270. margin-bottom: 10px;
  271. background: red;
  272. }
  273. .row {
  274. line-height: 17px;
  275. font-family: PingFang SC, PingFang SC;
  276. font-size: 12px;
  277. color: #999999;
  278. margin-bottom: 5px;
  279. }
  280. .collect {
  281. position: absolute;
  282. right: 0;
  283. top: 10px;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. width: 66px;
  288. height: 24px;
  289. border-radius: 12px 0px 0px 12px;
  290. border: 1px solid #CCCCCC;
  291. .iconfont {
  292. font-size: 14px;
  293. margin-right: 4px;
  294. }
  295. font-family: Source Han Sans SC,
  296. Source Han Sans SC;
  297. font-size: 12px;
  298. color: #666666;
  299. }
  300. }
  301. .division {
  302. width: 375px;
  303. height: 40px;
  304. background: #FFFFFF;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. font-family: Source Han Sans SC, Source Han Sans SC;
  309. font-weight: bold;
  310. font-size: 14px;
  311. color: #333333;
  312. margin-top: 10px;
  313. .line {
  314. width: 20px;
  315. height: 1px;
  316. background: #333333;
  317. margin: 0 4px;
  318. }
  319. }
  320. .footer {
  321. position: fixed;
  322. display: flex;
  323. width: 100vw;
  324. height: 65px;
  325. background: #FFFFFF;
  326. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  327. bottom: 0;
  328. left: 0;
  329. padding: 10px;
  330. padding-top: 5px;
  331. box-sizing: border-box;
  332. .fun-but {
  333. display: flex;
  334. flex-direction: column;
  335. align-items: center;
  336. padding-top: 8px;
  337. width: 50px;
  338. border-radius: 5px;
  339. flex-shrink: 0;
  340. .iconfont {
  341. font-size: 16px;
  342. color: #333333;
  343. line-height: 20px !important;
  344. }
  345. .text {
  346. line-height: 14px !important;
  347. font-family: PingFang SC, PingFang SC;
  348. font-size: 10px;
  349. color: #333333;
  350. margin-top: 4px;
  351. }
  352. }
  353. .place-an-order {
  354. flex: 1;
  355. display: flex;
  356. align-items: center;
  357. justify-content: center;
  358. height: 45px;
  359. background: #C30D23;
  360. border-radius: 5px;
  361. margin-left: 10px;
  362. font-family: PingFang SC, PingFang SC;
  363. font-weight: bold;
  364. font-size: 14px;
  365. color: #FFFFFF;
  366. }
  367. }
  368. </style>