微信

index.vue 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="mainPage">
  3. <div class="residue">
  4. <i class="iconfont icon-gantanhao"></i>
  5. <span>仅剩{{data.TotalCount - data.UsedCount}}张券可以领取!</span>
  6. </div>
  7. <div class="logo">
  8. <img :src="logo" alt="">
  9. </div>
  10. <div class="banner" v-if="!video">
  11. <img :src="data.CoverUrl" alt="" width="100%" height="100%">
  12. </div>
  13. <div class="content">
  14. <div class="title">{{data.CardName}}</div>
  15. <div class="video" v-if='video'>
  16. <video :src="data.VideoUrl" width="100%" height="100%"></video>
  17. </div>
  18. <div class="text">
  19. <div>
  20. <i class="icon-shuoming iconfont"></i>
  21. <span>卡券使用说明</span>
  22. </div>
  23. <pre>{{data.Share.CardUseInstruction}}</pre>
  24. </div>
  25. <div class="text">
  26. <div>
  27. <i class="icon-kaquan iconfont"></i>
  28. <span>卡券有效期</span>
  29. </div>
  30. <pre>有效期至{{toolClass.dateFormat(data.EndDate)}},请在有效期结束前使用, 过期作废;</pre>
  31. </div>
  32. <div class="text">
  33. <div>
  34. <i class="icon-dingwei iconfont"></i>
  35. <span>服务网点</span>
  36. </div>
  37. <pre>{{data.address}}</pre>
  38. </div>
  39. <div class="submit" v-if="button" @click="receive">确认领取</div>
  40. <div class="submit" v-else>点击右上角分享给客户</div>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import wxsdk from '../../../util/share'
  46. import logo from '../../../common/icon/logoTop.png'
  47. import { createNamespacedHelpers } from 'vuex'
  48. const { mapState: mapShareState, mapActions: mapShareActions } = createNamespacedHelpers('share')
  49. const { mapState: mapAppState, mapActions: mapAppActions } = createNamespacedHelpers('app')
  50. export default {
  51. data () {
  52. return {
  53. logo,
  54. video: true,
  55. button: true,
  56. data: {
  57. Share: {}
  58. }
  59. }
  60. },
  61. computed: {
  62. ...mapShareState({
  63. cardShare: x => x.cardShare,
  64. couponShare: x => x.couponShare
  65. }),
  66. ...mapAppState({
  67. caseList: x => x.CaseList
  68. })
  69. },
  70. created () {
  71. if (this.$route.params) {
  72. let that = this
  73. Object.keys(this.$route.params).forEach(function (key) {
  74. that.$route.query[key] = that.$route.params[key]
  75. })
  76. }
  77. if (this.$route.query.shareType === 'share') {
  78. this.button = false
  79. }
  80. this.getCaseList().then(() => {
  81. this.init()
  82. })
  83. },
  84. methods: {
  85. ...mapShareActions(['getCardShare', 'getCouponShare', 'setChannelCardShare', 'setChannelCouponShare']),
  86. ...mapAppActions(['getCaseList']),
  87. init () {
  88. if (this.$route.query.type === 'card') {
  89. this.getCardShare({ id: this.$route.query.id }).then(() => {
  90. this.data = this.cardShare.Card
  91. this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
  92. if (!this.data.VideoUrl) {
  93. this.video = false
  94. }
  95. this.sdk()
  96. })
  97. } else {
  98. this.getCouponShare({ id: this.$route.query.id }).then(() => {
  99. this.data = this.cardShare.Card
  100. this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
  101. if (!this.data.VideoUrl) {
  102. this.video = false
  103. }
  104. this.sdk()
  105. })
  106. }
  107. },
  108. receive () {
  109. if (this.$route.query.type === 'card') {
  110. this.setChannelCardShare({ id: this.$route.query.id }).then(() => {
  111. this.$router.push({ name: 'receiveResults', query: { type: 'success' } })
  112. }).catch((err) => {
  113. this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
  114. console.log(err)
  115. })
  116. } else {
  117. this.setChannelCouponShare({ id: this.$route.query.id }).then(() => {
  118. this.$router.push({ name: 'receiveResults', query: { type: 'success' } })
  119. }).catch((err) => {
  120. this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
  121. console.log(err)
  122. })
  123. }
  124. },
  125. random () {
  126. let rnd = ''
  127. for (let i = 0; i < 5; i++) {
  128. rnd += Math.floor(Math.random() * 10)
  129. }
  130. let timestamp = new Date().valueOf()
  131. return `${rnd}${timestamp}`
  132. },
  133. sdk () {
  134. let logo = this.logo.substring(2, this.logo.length)
  135. wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
  136. title: '领取卡券',
  137. desc: this.data.Share.CardShareInfo,
  138. link: `${window.location.origin}${window.location.pathname}#/receiveShared/${this.$route.query.id}/${this.$route.query.salesid}/${this.$route.query.type}/receive`,
  139. thu_image: `${window.location.origin}${window.location.pathname}${logo}`
  140. })
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. @import 'page.scss';
  147. </style>