detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <view>
  3. <swiper
  4. class="swiper"
  5. circular
  6. v-if="slides.length"
  7. :indicator-dots="slides.length > 1"
  8. indicator-color="#DC808B"
  9. indicator-active-color="#C30D23"
  10. >
  11. <swiper-item class="swiper-item" v-for="item in slides" :key="item.url">
  12. <image
  13. class="image"
  14. :src="item.cover"
  15. mode="aspectFill"
  16. lazy-load="true"
  17. />
  18. <view class="qrcode" @click="saveQrcode">
  19. <text class="iconfont icon-xiazai" />
  20. 二维码
  21. </view>
  22. </swiper-item>
  23. </swiper>
  24. <view class="head">
  25. <view class="line1">
  26. <view class="left">
  27. <text class="iconfont icon-biaoqian" />
  28. {{ detail.renderingstype }}
  29. </view>
  30. <view
  31. class="right"
  32. hover-class="navigator-hover"
  33. @click="collectLoading ? '' : handleCollect(detail.iscollect)"
  34. >
  35. <u-loading-icon v-if="collectLoading" size="20" />
  36. <block v-else>
  37. <text
  38. v-if="detail.iscollect == 0"
  39. class="iconfont icon-weishoucang"
  40. />
  41. <text
  42. v-else
  43. class="iconfont icon-yishoucang"
  44. style="color: #ffc300"
  45. />
  46. 收藏
  47. </block>
  48. </view>
  49. </view>
  50. <view class="title">{{ detail.title }}</view>
  51. <view class="subtitle" v-if="detail.subtitle">{{ detail.subtitle }}</view>
  52. </view>
  53. <scroll-view
  54. v-if="productList.length"
  55. class="product-list"
  56. scroll-x
  57. lower-threshold="200"
  58. enable-flex
  59. @scrolltolower="scrolltolower"
  60. >
  61. <navigator
  62. class="product"
  63. v-for="item in productList"
  64. :key="item.sa_fadid"
  65. :url="'/packageCase/product/detail?id=' + item.sa_fadid"
  66. hover-class="navigator-hover"
  67. >
  68. <u--image
  69. :src="item.cover"
  70. :lazy-load="true"
  71. :width="tovw(112)"
  72. :height="tovw(112)"
  73. radius="5"
  74. >
  75. <template v-slot:loading>
  76. <u-loading-icon color="red"></u-loading-icon>
  77. </template>
  78. </u--image>
  79. <view class="label u-line-1">
  80. {{ item.name }}
  81. </view>
  82. </navigator>
  83. </scroll-view>
  84. <view class="introduce" v-if="detail.notes">
  85. <view class="introduce-title"> 产品介绍 </view>
  86. <view class="introduce-text">
  87. {{ detail.notes }}
  88. </view>
  89. </view>
  90. <storeInfo />
  91. <view style="position: absolute; z-index: -999; top: 0">
  92. <l-painter
  93. ref="painter"
  94. hidden
  95. css="padding:10px;background:#fff;width: 148px;"
  96. >
  97. <l-painter-view>
  98. <l-painter-view css="margin: 0 auto;width: 128px;">
  99. <l-painter-qrcode
  100. :text="detail.appleturl"
  101. css="width: 128px; height: 128px;color:#000;"
  102. />
  103. </l-painter-view>
  104. <l-painter-view
  105. css="width: 108px;text-align: center;margin: 10px auto 0;"
  106. >
  107. <l-painter-text :text="detail.title" />
  108. </l-painter-view>
  109. </l-painter-view>
  110. </l-painter>
  111. </view>
  112. <bottomForm
  113. type="效果图"
  114. :shareuserid="shareUserid"
  115. ownertable="sat_sharematerial"
  116. :ownerid="sat_sharematerialid"
  117. />
  118. </view>
  119. </template>
  120. <script>
  121. import { winTheCustomer } from "../../utils/share";
  122. import lPainter from "../../uni_modules/lime-painter/components/l-painter/l-painter.vue";
  123. import lPainterText from "../../uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue";
  124. import lPainterView from "../../uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue";
  125. import lPainterQrcode from "../../uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue";
  126. export default {
  127. components: { lPainter, lPainterQrcode, lPainterText, lPainterView },
  128. data() {
  129. return {
  130. sat_sharematerialid: null,
  131. detail: {},
  132. slides: [],
  133. collectLoading: false,
  134. content: {
  135. pageNumber: 1,
  136. pageTotal: 1,
  137. pageSize: 20,
  138. where: {
  139. condition: "",
  140. },
  141. },
  142. productList: [],
  143. shareUserid: 0,
  144. };
  145. },
  146. onLoad(options) {
  147. this.sat_sharematerialid = options.id;
  148. this.isInitializeLogin(render.bind(this));
  149. function render() {
  150. this.getDetail(true);
  151. this.scrolltolower();
  152. this.shareUserid = winTheCustomer(options.shareUserid || 0, "效果图", {
  153. ownertable: "sat_sharematerial",
  154. ownerid: this.sat_sharematerialid,
  155. });
  156. }
  157. },
  158. methods: {
  159. getDetail(init = false) {
  160. if (!init) return;
  161. this.$Http
  162. .basic({
  163. id: 20240415164302,
  164. content: {
  165. sat_sharematerialid: this.sat_sharematerialid,
  166. },
  167. })
  168. .then((res) => {
  169. console.log("获取效果图详情", res);
  170. if (this.cutoff(res.msg)) return;
  171. this.detail = res.data;
  172. this.slides = res.data.attinfos_pic.map((v) => {
  173. return {
  174. cover: this.getSpecifiedImage(v.attinfos[0], "compressed"),
  175. url: v.attinfos[0].url,
  176. };
  177. });
  178. uni.setNavigationBarTitle({
  179. title: res.data.title,
  180. });
  181. });
  182. },
  183. handleCollect(iscollect) {
  184. this.collectLoading = true;
  185. this.$Http
  186. .basic({
  187. id: 20240416133702,
  188. content: {
  189. ownertable: "sat_sharematerial",
  190. ownerid: this.detail.sat_sharematerialid,
  191. type: 1,
  192. },
  193. })
  194. .then((res) => {
  195. console.log("收藏", res);
  196. this.collectLoading = false;
  197. if (this.cutoff(res.msg)) return;
  198. this.detail.iscollect = iscollect ? 0 : 1;
  199. });
  200. },
  201. saveQrcode() {
  202. let that = this;
  203. that.$refs.painter.canvasToTempFilePathSync({
  204. fileType: "jpg",
  205. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  206. pathType: "url",
  207. quality: 1,
  208. success: (res) => {
  209. console.log(res.tempFilePath);
  210. // 非H5 保存到相册
  211. // H5 提示用户长按图另存
  212. uni.saveImageToPhotosAlbum({
  213. filePath: res.tempFilePath,
  214. success: function (e) {
  215. uni.showModal({
  216. title: "提示",
  217. content: "图片已保存到系统相册",
  218. showCancel: false,
  219. });
  220. that.loading = false;
  221. },
  222. fail: ({ errMsg }) => {
  223. if (errMsg == "saveImageToPhotosAlbum:fail auth deny") {
  224. uni.showModal({
  225. title: "提示",
  226. content: "请授权添加到相册权限后再试!",
  227. showCancel: false,
  228. complete: (complete) => {
  229. uni.openSetting({
  230. success: (res) => {
  231. that.loading = false;
  232. if (res.authSetting["scope.writePhotosAlbum"]) {
  233. this.saveTheImage();
  234. } else {
  235. uni.showModal({
  236. title: "提示",
  237. content: "未获取授权!已取消保存",
  238. showCancel: false,
  239. });
  240. }
  241. },
  242. });
  243. },
  244. });
  245. } else {
  246. that.loading = false;
  247. uni.showModal({
  248. title: "提示",
  249. content: "已取消保存",
  250. showCancel: false,
  251. });
  252. }
  253. },
  254. });
  255. },
  256. });
  257. },
  258. getSheraDate() {
  259. let detail = this.detail;
  260. return {
  261. title: detail.title, // 标题
  262. path:
  263. "/packageCase/imgs/detail?id=" +
  264. detail.sat_sharematerialid +
  265. "&shareUserid=" +
  266. this.shareUserid, // 分享路径
  267. imageUrl:
  268. this.detail.attinfos.find((v) => v.usetype == "sat_sharematerial")
  269. .url || "", // 分享图
  270. };
  271. },
  272. scrolltolower() {
  273. let content = this.content;
  274. content.sat_sharematerialid = this.sat_sharematerialid;
  275. if (content.pageNumber > content.pageTotal)
  276. return console.log("已加载全部单品");
  277. this.$Http
  278. .basic({
  279. id: 20240419135802,
  280. content,
  281. })
  282. .then((res) => {
  283. console.log("关联单品", res);
  284. if (this.cutoff(res.msg)) return;
  285. res.data = res.data.map((v) => {
  286. v.cover = v.attinfos.length
  287. ? this.getSpecifiedImage(
  288. v.attinfos.find((s) => s.usetype == "sa_fad") || v.attinfos[0]
  289. )
  290. : uni.getStorageSync("site").logo || "";
  291. return v;
  292. });
  293. this.productList =
  294. res.pageNumber == 1 ? res.data : this.productList.concat(res.data);
  295. content.pageNumber = res.pageNumber + 1;
  296. content.pageTotal = res.pageTotal;
  297. });
  298. },
  299. },
  300. onShareAppMessage(res) {
  301. return this.getSheraDate();
  302. },
  303. onShareTimeline() {
  304. return this.getSheraDate();
  305. },
  306. };
  307. </script>
  308. <style lang="scss">
  309. .swiper {
  310. width: 375px;
  311. height: 231px;
  312. background: #f5f5f5;
  313. border-radius: 5px;
  314. box-sizing: border-box;
  315. .swiper-item {
  316. position: relative;
  317. width: 100%;
  318. height: 100%;
  319. .image {
  320. width: 100%;
  321. height: 100%;
  322. }
  323. .qrcode {
  324. position: absolute;
  325. display: flex;
  326. align-items: center;
  327. justify-content: center;
  328. top: 10px;
  329. right: 10px;
  330. width: 70px;
  331. height: 25px;
  332. background: rgba($color: #333333, $alpha: 0.5);
  333. font-size: 12px;
  334. color: #ffffff;
  335. .iconfont {
  336. margin-right: 4px;
  337. }
  338. }
  339. }
  340. }
  341. .head {
  342. background: #fff;
  343. padding: 8px 10px 15px;
  344. margin-bottom: 10px;
  345. .line1 {
  346. display: flex;
  347. justify-content: space-between;
  348. align-items: flex-end;
  349. .left {
  350. .iconfont {
  351. margin-right: 4px;
  352. font-size: 12px;
  353. }
  354. line-height: 17px;
  355. font-size: 12px;
  356. color: #999999;
  357. }
  358. .right {
  359. display: flex;
  360. align-items: center;
  361. justify-content: center;
  362. width: 80px;
  363. height: 24px;
  364. border-radius: 12px;
  365. border: 1px solid #cccccc;
  366. font-family: PingFang SC, PingFang SC;
  367. font-size: 12px;
  368. color: #333333;
  369. .iconfont {
  370. margin-right: 5px;
  371. }
  372. }
  373. }
  374. .title {
  375. line-height: 20px;
  376. font-family: PingFang SC, PingFang SC;
  377. font-weight: bold;
  378. font-size: 14px;
  379. color: #333333;
  380. margin: 10px 0;
  381. }
  382. .subtitle {
  383. line-height: 17px;
  384. font-family: PingFang SC, PingFang SC;
  385. font-size: 12px;
  386. color: #666666;
  387. }
  388. }
  389. .product-list {
  390. display: flex;
  391. width: 100vw;
  392. height: 162px;
  393. white-space: nowrap;
  394. box-sizing: border-box;
  395. padding-top: 10px;
  396. background: #fff;
  397. margin-bottom: 10px;
  398. .product {
  399. width: 112px;
  400. height: 142px;
  401. margin-left: 10px;
  402. flex-shrink: 0;
  403. background: #fff;
  404. .label {
  405. width: 112px;
  406. line-height: 20px;
  407. font-family: PingFang SC, PingFang SC;
  408. font-size: 14px;
  409. color: #333333;
  410. margin-top: 10px;
  411. white-space: Normal;
  412. }
  413. }
  414. }
  415. .introduce {
  416. background: #fff;
  417. padding: 0 10px;
  418. &-title {
  419. line-height: 45px;
  420. background: #ffffff;
  421. font-family: PingFang SC, PingFang SC;
  422. font-weight: bold;
  423. font-size: 16px;
  424. color: #333333;
  425. }
  426. &-text {
  427. line-height: 20px;
  428. font-family: PingFang SC, PingFang SC;
  429. font-size: 14px;
  430. color: #333333;
  431. padding-bottom: 10px;
  432. }
  433. }
  434. </style>