index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="content">
  3. <!-- <template v-if="data.type == 0">
  4. <div class="mask" style="position: absolute">
  5. <web-view :src="data.longLink"></web-view>
  6. </div>
  7. </template> -->
  8. <div class="g-card g-pad20 cc ac">
  9. <!-- 个人小程序,企业小程序 -->
  10. <template v-if="[7, 9].includes(+data.type)">
  11. <div class="">{{ data.name || '小程序' }}</div>
  12. <image
  13. style="width: 200px; height: 200px; display: block; margin: 20px auto 30px"
  14. :src="data.avatar"
  15. show-menu-by-longpress
  16. fit="fit"></image>
  17. <button class="" type="primary" @tap="open()">点击打开{{ data.name || '小程序' }}</button>
  18. </template>
  19. <template v-else>
  20. <!-- 员工活码,客群活码 门店导购活码 门店群活码 -->
  21. <div v-if="[4, 5, 6, 8].includes(+data.type)" class="mt10">
  22. {{ data.name || touchTypeDict[data.type].name }}
  23. </div>
  24. <div v-else class="al bfc-o">
  25. <image class="fl mr10" style="width: 50px; height: 50px" :src="data.avatar" show-menu-by-longpress></image>
  26. <div class="toe">{{ data.name || '名称' }}</div>
  27. <div class="tips mt20 toe">{{ data.describe || '描述' }}</div>
  28. </div>
  29. <image
  30. style="width: 200px; height: 200px; margin: 20px 0 30px"
  31. :src="data.qrCode"
  32. show-menu-by-longpress></image>
  33. <div v-if="[5, 6, 8].includes(+data.type)" class="toe">长按二维码保存后,使用微信扫一扫打开</div>
  34. <div v-else class="">长按二维码{{ touchTypeDict[data.type].previewMobileTitle }}</div>
  35. </template>
  36. </div>
  37. <!-- <canvas canvas-id="mycanvas" id="mycanvas" type="2d" style="width: 500px; height: 500px; display: none"></canvas> -->
  38. </view>
  39. </template>
  40. <script>
  41. // const jsQR = require('jsqr')
  42. import { getDetail } from '@/api/intelligentShortLink'
  43. import { touchTypeDict } from './mixin'
  44. export default {
  45. data() {
  46. return {
  47. loading: false,
  48. data: {},
  49. touchTypeDict,
  50. id: '',
  51. promotionId: '',
  52. // qrCodeUrl: '',
  53. }
  54. },
  55. onLoad(options) {
  56. console.log('onLoad options', options)
  57. this.id = options.id
  58. this.promotionId = options.promotionId
  59. },
  60. onReady() {
  61. this.getDetail(this.id + (this.promotionId ? '/' + this.promotionId : ''))
  62. },
  63. created() {
  64. // let id = this.$route.query.id
  65. // var pages = getCurrentPages()
  66. // var page = pages[pages.length - 1]
  67. // console.log('当前页面路由地址数据信息', page)
  68. },
  69. mounted() {},
  70. methods: {
  71. getDetail(path) {
  72. console.log('path', path)
  73. this.loading = true
  74. getDetail(path)
  75. .then(({ data }) => {
  76. // if ([5, 6].includes(+data.type)) {
  77. // var query = uni.createSelectorQuery().in(this)
  78. // query
  79. // .select('#mycanvas')
  80. // .fields({ node: true, size: true })
  81. // .exec((res) => {
  82. // var canvas = res[0].node
  83. // // var ctx = uni.createCanvasContext('mycanvas', this)
  84. // var ctx = canvas.getContext('2d')
  85. // // Canvas 画布的实际绘制宽高
  86. // const width = res[0].width
  87. // const height = res[0].height
  88. // // 初始化画布大小
  89. // const dpr = wx.getWindowInfo().pixelRatio
  90. // debugger
  91. // canvas.width = width * dpr
  92. // canvas.height = height * dpr
  93. // // ctx.scale(1, 1)
  94. // var img = canvas.createImage()
  95. // img.onload = function () {
  96. // ctx.drawImage(img, 0, 0)
  97. // // canvas.toDataURL()
  98. // var imageData = ctx.getImageData(0, 0, img.width, img.height)
  99. // var code = jsQR(imageData.data, imageData.width, imageData.height, {})
  100. // if (code) {
  101. // console.log('code', code.data)
  102. // this.qrCodeUrl = code.data
  103. // } else {
  104. // console.log('识别错误')
  105. // }
  106. // // uni.canvasGetImageData({
  107. // // mycanvas: 'mycanvas',
  108. // // x: 0,
  109. // // y: 0,
  110. // // width: img.width,
  111. // // height: img.height,
  112. // // success(imageData) {
  113. // // var code = jsQR(imageData.data, imageData.width, imageData.height, {
  114. // // inversionAttempts: 'dontInvert',
  115. // // })
  116. // // if (code) {
  117. // // console.log('code', code.data)
  118. // // } else {
  119. // // console.log('识别错误')
  120. // // }
  121. // // },
  122. // // })
  123. // }
  124. // img.src = data.qrCode
  125. // })
  126. // }
  127. this.data = data
  128. console.log('data', data)
  129. uni.setNavigationBarTitle({
  130. title: touchTypeDict[data.type].previewMobileTitle,
  131. // title: data.shortLinkName
  132. })
  133. })
  134. .catch(() => {})
  135. .finally(() => {
  136. this.loading = false
  137. })
  138. },
  139. open() {
  140. wx.navigateToMiniProgram({
  141. appId: this.data.appId,
  142. path: this.data.longLink,
  143. // extraData: {
  144. // foo: 'bar',
  145. // },
  146. // envVersion: 'develop',
  147. success(res) {
  148. // 打开成功
  149. },
  150. })
  151. },
  152. // copy() {
  153. // uni.setClipboardData({
  154. // data: this.data.longLink,
  155. // success: function () {
  156. // console.log('success')
  157. // },
  158. // })
  159. // },
  160. },
  161. }
  162. </script>
  163. <style lang="scss" scoped></style>