detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <My_listbox ref="List" @getlist="getDetail">
  3. <swiper class="swiper" 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.mainclassnames }}
  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.name }}</view>
  30. <view class="subtitle">型号:{{ detail.model || '--' }}</view>
  31. <view class="subtitle">尺寸:{{ detail.spec || '--' }}</view>
  32. <view class="subtitle">价格:{{ CNY(detail.price) || '--' }}</view>
  33. </view>
  34. <view class="introduce">
  35. <block v-if="detail.content">
  36. <view class="introduce-title">
  37. 产品介绍
  38. </view>
  39. <view class="introduce-text">
  40. <u-parse :content="detail.content" />
  41. </view>
  42. </block>
  43. </view>
  44. <bottom1 />
  45. <view style="position: absolute;z-index: -999;top: 0;">
  46. <l-painter ref="painter" hidden css="padding:10px;background:#fff;width: 148px;">
  47. <l-painter-view>
  48. <l-painter-view css="margin: 0 auto;width: 128px;">
  49. <l-painter-qrcode :text="detail.appleturl" css="width: 128px; height: 128px;color:#000;" />
  50. </l-painter-view>
  51. <l-painter-view css="width: 108px;text-align: center;margin: 10px auto 0;">
  52. <l-painter-text :text="detail.name" />
  53. </l-painter-view>
  54. </l-painter-view>
  55. </l-painter>
  56. </view>
  57. </My_listbox>
  58. </template>
  59. <script>
  60. import bottom1 from "../../components/bottomModules/bottom1.vue"
  61. import lPainter from "../../uni_modules/lime-painter/components/l-painter/l-painter.vue"
  62. import lPainterText from "../../uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue"
  63. import lPainterView from "../../uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue"
  64. import lPainterQrcode from "../../uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue"
  65. export default {
  66. components: { bottom1, lPainter, lPainterQrcode, lPainterText, lPainterView },
  67. data() {
  68. return {
  69. sa_fadid: null,
  70. detail: {},
  71. slides: [],
  72. collectLoading: false
  73. }
  74. },
  75. onLoad(options) {
  76. this.sa_fadid = options.id;
  77. this.getDetail(true);
  78. },
  79. methods: {
  80. getDetail(init = false) {
  81. if (!init) return;
  82. this.$Http.basic({
  83. "id": 20240418141002,
  84. "content": {
  85. "sa_fadid": this.sa_fadid
  86. },
  87. }).then(res => {
  88. this.$refs.List.RefreshToComplete()
  89. console.log("获取单品详情", res)
  90. if (this.cutoff(res.msg)) return;
  91. this.detail = res.data;
  92. this.slides = res.data.attinfos_pic.map(v => {
  93. return {
  94. cover: this.getSpecifiedImage(v.attinfos[0]),
  95. url: v.attinfos[0].url
  96. }
  97. })
  98. uni.setNavigationBarTitle({
  99. title: res.data.name
  100. });
  101. })
  102. },
  103. handleCollect(iscollect) {
  104. this.collectLoading = true;
  105. this.$Http.basic({
  106. "id": 20240416133702,
  107. "content": {
  108. "ownertable": "sa_fad",
  109. "ownerid": this.detail.sa_fadid,
  110. "type": 1
  111. },
  112. }).then(res => {
  113. console.log("收藏", res)
  114. this.collectLoading = false;
  115. if (this.cutoff(res.msg)) return;
  116. this.detail.iscollect = iscollect ? 0 : 1
  117. })
  118. },
  119. saveQrcode() {
  120. let that = this;
  121. that.$refs.painter.canvasToTempFilePathSync({
  122. fileType: "jpg",
  123. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  124. pathType: 'url',
  125. quality: 1,
  126. success: (res) => {
  127. console.log(res.tempFilePath);
  128. // 非H5 保存到相册
  129. // H5 提示用户长按图另存
  130. uni.saveImageToPhotosAlbum({
  131. filePath: res.tempFilePath,
  132. success: function (e) {
  133. uni.showModal({
  134. title: '提示',
  135. content: '图片已保存到系统相册',
  136. showCancel: false
  137. })
  138. that.loading = false;
  139. },
  140. fail: ({ errMsg }) => {
  141. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  142. uni.showModal({
  143. title: '提示',
  144. content: '请授权添加到相册权限后再试!',
  145. showCancel: false,
  146. complete: (complete) => {
  147. uni.openSetting({
  148. success: res => {
  149. that.loading = false;
  150. if (res.authSetting['scope.writePhotosAlbum']) {
  151. this.saveTheImage()
  152. } else {
  153. uni.showModal({
  154. title: '提示',
  155. content: '未获取授权!已取消保存',
  156. showCancel: false,
  157. })
  158. }
  159. }
  160. })
  161. },
  162. })
  163. } else {
  164. that.loading = false;
  165. uni.showModal({
  166. title: '提示',
  167. content: '已取消保存',
  168. showCancel: false,
  169. })
  170. }
  171. },
  172. });
  173. },
  174. });
  175. }, getSheraDate() {
  176. let detail = this.detail
  177. return {
  178. title: detail.name, // 标题
  179. path: "/packageCase/product/detail?id=" + detail.sa_fadid, // 分享路径
  180. imageUrl: this.detail.attinfos.find(v => v.usetype == "sa_fad").url || ""// 分享图
  181. };
  182. }
  183. },
  184. onShareAppMessage(res) {
  185. return this.getSheraDate()
  186. },
  187. onShareTimeline() {
  188. return this.getSheraDate()
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. .swiper {
  194. width: 375px;
  195. height: 231px;
  196. background: #F5F5F5;
  197. border-radius: 5px;
  198. box-sizing: border-box;
  199. .swiper-item {
  200. position: relative;
  201. width: 100%;
  202. height: 100%;
  203. .image {
  204. width: 100%;
  205. height: 100%;
  206. }
  207. .qrcode {
  208. position: absolute;
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. top: 10px;
  213. right: 10px;
  214. width: 70px;
  215. height: 25px;
  216. background: rgba($color: #333333, $alpha: 0.5);
  217. font-size: 12px;
  218. color: #FFFFFF;
  219. .iconfont {
  220. margin-right: 4px;
  221. }
  222. }
  223. }
  224. }
  225. .head {
  226. background: #fff;
  227. padding: 8px 10px 15px;
  228. .line1 {
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: flex-end;
  232. .left {
  233. .iconfont {
  234. margin-right: 4px;
  235. font-size: 12px;
  236. }
  237. line-height: 17px;
  238. font-size: 12px;
  239. color: #999999;
  240. }
  241. .right {
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. width: 80px;
  246. height: 24px;
  247. border-radius: 12px;
  248. border: 1px solid #CCCCCC;
  249. font-family: PingFang SC, PingFang SC;
  250. font-size: 12px;
  251. color: #333333;
  252. .iconfont {
  253. margin-right: 5px;
  254. }
  255. }
  256. }
  257. .title {
  258. line-height: 20px;
  259. font-family: PingFang SC, PingFang SC;
  260. font-weight: bold;
  261. font-size: 14px;
  262. color: #333333;
  263. margin: 10px 0;
  264. }
  265. .subtitle {
  266. line-height: 17px;
  267. font-family: PingFang SC, PingFang SC;
  268. font-size: 12px;
  269. color: #666666;
  270. margin-top: 5px;
  271. }
  272. }
  273. .introduce {
  274. background: #fff;
  275. margin-top: 10px;
  276. padding: 0 10px;
  277. &-title {
  278. line-height: 45px;
  279. background: #FFFFFF;
  280. font-family: PingFang SC, PingFang SC;
  281. font-weight: bold;
  282. font-size: 16px;
  283. color: #333333;
  284. }
  285. &-text {
  286. line-height: 20px;
  287. font-family: PingFang SC, PingFang SC;
  288. font-size: 14px;
  289. color: #333333;
  290. padding-bottom: 10px;
  291. }
  292. }
  293. </style>