detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <My_listbox ref="List" @getlist="getDetail">
  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. </My_listbox>
  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. this.$refs.List.RefreshToComplete()
  109. console.log("获取效果图详情", res)
  110. if (this.cutoff(res.msg)) return;
  111. this.detail = res.data;
  112. this.slides = res.data.attinfos_pic.map(v => {
  113. return {
  114. cover: this.getSpecifiedImage(v.attinfos[0], 'compressed'),
  115. url: v.attinfos[0].url
  116. }
  117. })
  118. uni.setNavigationBarTitle({
  119. title: res.data.title
  120. });
  121. })
  122. },
  123. handleCollect(iscollect) {
  124. this.collectLoading = true;
  125. this.$Http.basic({
  126. "id": 20240416133702,
  127. "content": {
  128. "ownertable": "sat_sharematerial",
  129. "ownerid": this.detail.sat_sharematerialid,
  130. "type": 1
  131. },
  132. }).then(res => {
  133. console.log("收藏", res)
  134. this.collectLoading = false;
  135. if (this.cutoff(res.msg)) return;
  136. this.detail.iscollect = iscollect ? 0 : 1
  137. })
  138. },
  139. saveQrcode() {
  140. let that = this;
  141. that.$refs.painter.canvasToTempFilePathSync({
  142. fileType: "jpg",
  143. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  144. pathType: 'url',
  145. quality: 1,
  146. success: (res) => {
  147. console.log(res.tempFilePath);
  148. // 非H5 保存到相册
  149. // H5 提示用户长按图另存
  150. uni.saveImageToPhotosAlbum({
  151. filePath: res.tempFilePath,
  152. success: function (e) {
  153. uni.showModal({
  154. title: '提示',
  155. content: '图片已保存到系统相册',
  156. showCancel: false
  157. })
  158. that.loading = false;
  159. },
  160. fail: ({ errMsg }) => {
  161. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  162. uni.showModal({
  163. title: '提示',
  164. content: '请授权添加到相册权限后再试!',
  165. showCancel: false,
  166. complete: (complete) => {
  167. uni.openSetting({
  168. success: res => {
  169. that.loading = false;
  170. if (res.authSetting['scope.writePhotosAlbum']) {
  171. this.saveTheImage()
  172. } else {
  173. uni.showModal({
  174. title: '提示',
  175. content: '未获取授权!已取消保存',
  176. showCancel: false,
  177. })
  178. }
  179. }
  180. })
  181. },
  182. })
  183. } else {
  184. that.loading = false;
  185. uni.showModal({
  186. title: '提示',
  187. content: '已取消保存',
  188. showCancel: false,
  189. })
  190. }
  191. },
  192. });
  193. },
  194. });
  195. },
  196. getSheraDate() {
  197. let detail = this.detail
  198. return {
  199. title: detail.title, // 标题
  200. path: "/packageCase/imgs/detail?id=" + detail.sat_sharematerialid, // 分享路径
  201. imageUrl: this.detail.attinfos.find(v => v.usetype == "sat_sharematerial").url || ""// 分享图
  202. };
  203. },
  204. scrolltolower() {
  205. let content = this.content;
  206. content.sat_sharematerialid = this.sat_sharematerialid;
  207. if (content.pageNumber > content.pageTotal) return console.log("已加载全部单品")
  208. this.$Http.basic({
  209. "id": 20240419135802,
  210. content
  211. }).then(res => {
  212. console.log("关联单品", res)
  213. if (this.cutoff(res.msg)) return;
  214. res.data = res.data.map(v => {
  215. v.cover = v.attinfos.length ? this.getSpecifiedImage(v.attinfos.find(s => s.usetype == "sa_fad") || v.attinfos[0]) : uni.getStorageSync("site").logo || ''
  216. return v
  217. })
  218. this.productList = res.pageNumber == 1 ? res.data : this.productList.concat(res.data);
  219. content.pageNumber = res.pageNumber + 1;
  220. content.pageTotal = res.pageTotal;
  221. })
  222. }
  223. },
  224. onShareAppMessage(res) {
  225. return this.getSheraDate()
  226. },
  227. onShareTimeline() {
  228. return this.getSheraDate()
  229. }
  230. }
  231. </script>
  232. <style lang="scss">
  233. .swiper {
  234. width: 375px;
  235. height: 231px;
  236. background: #F5F5F5;
  237. border-radius: 5px;
  238. box-sizing: border-box;
  239. .swiper-item {
  240. position: relative;
  241. width: 100%;
  242. height: 100%;
  243. .image {
  244. width: 100%;
  245. height: 100%;
  246. }
  247. .qrcode {
  248. position: absolute;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. top: 10px;
  253. right: 10px;
  254. width: 70px;
  255. height: 25px;
  256. background: rgba($color: #333333, $alpha: 0.5);
  257. font-size: 12px;
  258. color: #FFFFFF;
  259. .iconfont {
  260. margin-right: 4px;
  261. }
  262. }
  263. }
  264. }
  265. .head {
  266. background: #fff;
  267. padding: 8px 10px 15px;
  268. margin-bottom: 10px;
  269. .line1 {
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: flex-end;
  273. .left {
  274. .iconfont {
  275. margin-right: 4px;
  276. font-size: 12px;
  277. }
  278. line-height: 17px;
  279. font-size: 12px;
  280. color: #999999;
  281. }
  282. .right {
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. width: 80px;
  287. height: 24px;
  288. border-radius: 12px;
  289. border: 1px solid #CCCCCC;
  290. font-family: PingFang SC, PingFang SC;
  291. font-size: 12px;
  292. color: #333333;
  293. .iconfont {
  294. margin-right: 5px;
  295. }
  296. }
  297. }
  298. .title {
  299. line-height: 20px;
  300. font-family: PingFang SC, PingFang SC;
  301. font-weight: bold;
  302. font-size: 14px;
  303. color: #333333;
  304. margin: 10px 0;
  305. }
  306. .subtitle {
  307. line-height: 17px;
  308. font-family: PingFang SC, PingFang SC;
  309. font-size: 12px;
  310. color: #666666;
  311. }
  312. }
  313. .product-list {
  314. display: flex;
  315. width: 100vw;
  316. height: 162px;
  317. white-space: nowrap;
  318. box-sizing: border-box;
  319. padding-top: 10px;
  320. background: #fff;
  321. margin-bottom: 10px;
  322. .product {
  323. width: 112px;
  324. height: 142px;
  325. margin-left: 10px;
  326. flex-shrink: 0;
  327. background: #fff;
  328. .label {
  329. width: 112px;
  330. line-height: 20px;
  331. font-family: PingFang SC, PingFang SC;
  332. font-size: 14px;
  333. color: #333333;
  334. margin-top: 10px;
  335. white-space: Normal;
  336. }
  337. }
  338. }
  339. .introduce {
  340. background: #fff;
  341. padding: 0 10px;
  342. &-title {
  343. line-height: 45px;
  344. background: #FFFFFF;
  345. font-family: PingFang SC, PingFang SC;
  346. font-weight: bold;
  347. font-size: 16px;
  348. color: #333333;
  349. }
  350. &-text {
  351. line-height: 20px;
  352. font-family: PingFang SC, PingFang SC;
  353. font-size: 14px;
  354. color: #333333;
  355. padding-bottom: 10px;
  356. }
  357. }
  358. </style>