微信

index.vue 5.5KB

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