wx-points-commit.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="box" v-if="show" @touchmove.stop.prevent>
  3. <div class="boxIn">
  4. <div class="content">
  5. <img class="commit-star" src="https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/wx-points/points-commit.png">
  6. </img>
  7. <img v-if="source !== 'PUDONG' && source !== 'JINGAN'" class="commit-logo-default" src="https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/wx-points/kerry.png" />
  8. <img v-else class="commit-logo-ko" src="https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/wx-points/ko.png" />
  9. <div class="logo">
  10. </div>
  11. <div class="title">
  12. {{'您有消费积分未领取'}}
  13. </div>
  14. <div class="text">
  15. 如您的微信支付积分未到账,请于消费当日申请领取
  16. </div>
  17. <div @click="toWxPointsAuth" class="commit-btn" :class="{'commit-btn--blue': source === 'PUDONG','commit-btn--green': source === 'PUDONG', 'commit-btn--qhkc': isQHKC && source !== 'KIP' }">
  18. 去领取
  19. </div>
  20. <img @click="close('time')" class="commit-cancel" src="https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/wx-points/close.svg" />
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. /* https://kerryprops.atlassian.net/browse/KIP-15785 */
  27. import Vue from 'vue';
  28. import uni from '@/utils/uniHooks';
  29. import { mapState } from "vuex"
  30. import {
  31. wxEasyPointsCommitStatus
  32. } from '@/utils/api-kip.js'
  33. import { toLogin } from '@/utils'
  34. export default {
  35. created() {
  36. // this.handleGetPointsConfig()
  37. },
  38. data() {
  39. return {
  40. pointsConfig: null,
  41. show: false,
  42. clickToWxPointsAuth: false,
  43. pointsModalFlag: false
  44. };
  45. },
  46. computed: {
  47. // custTypeId: 0 默认版本,1 上海静安 2 上海浦东
  48. ...mapState({
  49. // custTypeId: 0
  50. custTypeId: state => state.custTypeId,
  51. mallId: (state) => state.mallId,
  52. source: (state) => state.source,
  53. }),
  54. isQHKC() {
  55. return ['8a88a9fd7f73ffcd017f968739870006', '8aaa82ea804d07cd0180516ff03b0008'].includes(this.mallId);
  56. }
  57. },
  58. methods: {
  59. async toWxPointsAuth() {
  60. console.log('授权微信无感积分')
  61. if (this.clickToWxPointsAuth) {
  62. console.log('授权微信无感积分重复点击')
  63. return
  64. }
  65. if (window.__wxjs_environment === 'miniprogram') {
  66. wx.miniProgram.navigateTo({
  67. "url": this.source === 'KIP' ? '/pages/points/wx-points-commit' : "/pages/package-parkingFee/wx-points-commit" // 去 login 页面 1 去登录
  68. })
  69. }
  70. this.show = false;
  71. this.clickToWxPointsAuth = false
  72. },
  73. async open(callback) {
  74. const isShow = this.checkShowFlag();
  75. if(!isShow) {
  76. return
  77. }
  78. const pointsCommitStatus = await wxEasyPointsCommitStatus();
  79. if(pointsCommitStatus.pointsCommitStatus === 'PENDING') {
  80. // 展示
  81. this.show = true
  82. callback && callback()
  83. }
  84. },
  85. isInToday(timestamp) {
  86. // 创建当前日期的对象
  87. const today = new Date();
  88. // 将当前日期的时间部分设置为零
  89. today.setHours(0, 0, 0, 0);
  90. // 创建时间戳日期的对象
  91. const dateOfTimestamp = new Date(timestamp);
  92. // 将时间戳的时间部分也设置为零
  93. dateOfTimestamp.setHours(0, 0, 0, 0);
  94. // 比较两个日期是否相等
  95. return today.getTime() === dateOfTimestamp.getTime();
  96. },
  97. checkShowFlag() {
  98. // 如果是支付宝,不弹出弹窗
  99. if(Vue.prototype.isAlipayClient) {
  100. return false
  101. }
  102. const nowTime = new Date()
  103. const nowTime00 = new Date().getTime()
  104. var lbs_easy_end_time = uni.getStorageSync('lbs_easy_end_time')
  105. if (lbs_easy_end_time) {
  106. const arr_lbsId = lbs_easy_end_time.filter(element => {
  107. return element.lbsId === this.$store.state?.lbsId
  108. })
  109. // 24小时内只弹出一次, 次日凌晨失效
  110. if (arr_lbsId.length > 0 && arr_lbsId[arr_lbsId.length - 1].time && this.isInToday(arr_lbsId[arr_lbsId.length - 1].time)) {
  111. return false
  112. }
  113. }
  114. return true
  115. },
  116. close() {
  117. this.show = false
  118. var arr_lbs_end_time = []
  119. if (uni.getStorageSync('lbs_easy_end_time')) {
  120. arr_lbs_end_time = uni.getStorageSync('lbs_easy_end_time')
  121. arr_lbs_end_time = arr_lbs_end_time.filter(item => item.lbsId !== this.$store.state?.lbsId);
  122. console.log('del_arr_lbs_end_time:::', arr_lbs_end_time)
  123. arr_lbs_end_time.push({
  124. lbsId: this.$store.state?.lbsId,
  125. time: new Date().getTime()
  126. })
  127. uni.setStorageSync("lbs_easy_end_time", arr_lbs_end_time)
  128. } else {
  129. arr_lbs_end_time.push({
  130. lbsId: this.$store.state?.lbsId,
  131. time: new Date().getTime()
  132. })
  133. uni.setStorageSync("lbs_easy_end_time", arr_lbs_end_time)
  134. }
  135. },
  136. }
  137. }
  138. </script>
  139. <style scoped>
  140. .box{
  141. position: fixed;
  142. z-index: 10000;
  143. width: 100vw;
  144. height: 100vh;
  145. background: rgba(0,0,0,0.7);
  146. top: 0;
  147. left: 0;
  148. }
  149. .boxIn {
  150. position: relative;
  151. width: 100%;
  152. height: 100%;
  153. }
  154. .content{
  155. position: relative;
  156. width: calc(100% - 110px);
  157. height: 245px;
  158. background: #FFFFFF;
  159. border-radius: 8px;
  160. margin: 0 auto;
  161. margin-top: 30vh;
  162. }
  163. .commit-star{
  164. position: absolute;
  165. width: calc(100vw - 40px);
  166. height: calc(48.1vw - 23.6px);
  167. top: calc(11.8px - 24.05vw);
  168. left: -33px;
  169. }
  170. .commit-logo-default{
  171. width: 84px;
  172. height:20px;
  173. position: relative;
  174. display: block;
  175. top: 15px;
  176. left: 30px;
  177. }
  178. .commit-logo-ko{
  179. width: 80px;
  180. height: 20px;
  181. position: relative;
  182. display: block;
  183. top: 15px;
  184. left: 35px;
  185. }
  186. .logo{
  187. height: 35px;
  188. border-bottom: 1rpx solid rgba(151,151,151,0.1);
  189. }
  190. .title{
  191. font-size: 16px;
  192. font-weight: 600;
  193. color: #333;
  194. text-align: center;
  195. margin-top: 22px;
  196. }
  197. .text{
  198. width: 180px;
  199. margin: 0 auto;
  200. margin-top: 8px;
  201. color: #999;
  202. font-size: 12px;
  203. text-align: center;
  204. }
  205. .text-content{
  206. width: calc(100% - 20px);
  207. line-height: 20px;
  208. }
  209. .commit-btn{
  210. width: calc(100vw - 180px);
  211. height: 40px;
  212. margin: 0 auto;
  213. margin-top: 27px;
  214. line-height: 40px;
  215. text-align: center;
  216. font-size: 15px;
  217. color: #fff;
  218. background: var(--k-color-primary-01, #064c8a);
  219. border-radius: 25px;
  220. box-shadow: 3px 3px 12px 0px var(--k-color-primary-01, #064c8a);
  221. }
  222. .commit-btn--blue {
  223. box-shadow: 3px 3px 12px 0px #13358E;
  224. background: #13358E;
  225. }
  226. .commit-btn--green {
  227. box-shadow: 3px 3px 12px 0px #25673C;
  228. background: #25673C;
  229. }
  230. .commit-btn--qhkc {
  231. box-shadow: 3px 3px 12px 0px #DF8443;
  232. background: #DF8443;
  233. }
  234. .commit-cancel{
  235. position: relative;
  236. display: block;
  237. margin: 0 auto;
  238. margin-top: 56px;
  239. width: 32px;
  240. height: 32px;
  241. }
  242. </style>