detail.vue 13 KB

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