wx-points-auth.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div class="box" v-if="show && source !== 'KIP' && source !== 'ALIPAY' " :style="{ bottom: bottom, }" @touchmove.stop.prevent>
  3. <div class="box-text">
  4. <div class="box-text-left">
  5. 开通支付快速积分,积分秒到账!
  6. </div>
  7. <div class="box-text-right">
  8. <div class="box-text-right-btn" :style="{ background: background ? background : backgroundList[custTypeId] }" @click="toWxPointsAuth('handle')">
  9. 立即开通
  10. <k-icon name="arrows-right" :size="5" class="box-text-right-icon" color="#fff"></k-icon>
  11. </div>
  12. <k-icon name="close" :size="7" class="box-text-right-icon-close" @click="close()" color="#999"></k-icon>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import { mapState } from "vuex"
  19. import {
  20. kipGetPointsConfig
  21. } from '@/utils/api-kip.js'
  22. import uni from '@/utils/uniHooks';
  23. const app = {}
  24. export default {
  25. props: {
  26. bottom: {
  27. type: String,
  28. default: '54px',
  29. },
  30. background: {
  31. type: String,
  32. default: '',
  33. },
  34. visibility: {
  35. type: String,
  36. default: 'hidden',
  37. }
  38. },
  39. created() {
  40. // this.handleGetPointsConfig()
  41. },
  42. watch: {
  43. },
  44. data() {
  45. return {
  46. pointsConfig: null,
  47. show: false,
  48. clickToWxPointsAuth: false,
  49. backgroundList:['#644A79','#143793','#2E663F']
  50. };
  51. },
  52. computed: {
  53. // custTypeId: 0 默认版本,1 上海静安 2 上海浦东
  54. ...mapState({
  55. // custTypeId: 0
  56. custTypeId: state => state.custTypeId,
  57. source: (state) => state.source,
  58. }),
  59. pointsModalFlag() {
  60. return this.$store.state.pointsModalFlag
  61. }
  62. },
  63. mounted() {
  64. // this.checkShowFlag()
  65. this.handleGetPointsConfig('init')
  66. },
  67. methods: {
  68. checkoutLogin() {
  69. this.toWxPointsAuth()
  70. },
  71. close() {
  72. this.show = false
  73. const arr_lbs_end_time = []
  74. if (uni.getStorageSync('lbs_end_time')) {
  75. arr_lbs_end_time = JSON.parse(uni.getStorageSync('lbs_end_time'))
  76. arr_lbs_end_time.push({
  77. lbsId: this.$store.state?.lbsId,
  78. time: new Date().getTime()
  79. })
  80. uni.setStorageSync("lbs_end_time", arr_lbs_end_time)
  81. uni.setStorageSync("ceshi", 4534534534534534534)
  82. } else {
  83. arr_lbs_end_time.push({
  84. lbsId: this.$store.state?.lbsId,
  85. time: new Date().getTime()
  86. })
  87. uni.setStorageSync("ceshi", 4534534534534534534)
  88. uni.setStorageSync("lbs_end_time", arr_lbs_end_time)
  89. }
  90. },
  91. checkShowFlag() {
  92. const nowTime = new Date()
  93. const nowTime00 = new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  94. var arr_lbs_end_time = [];
  95. if (uni.getStorageSync('lbs_end_time')) {
  96. console.log(555)
  97. arr_lbs_end_time = uni.getStorageSync('lbs_end_time')
  98. console.log(666)
  99. console.log('arr_lbs_end_time::', uni.getStorageSync('lbs_end_time'))
  100. arr_lbs_end_time.forEach(element => {
  101. if (element.lbsId === this.$store.state?.lbsId) {
  102. console.log(777)
  103. if (element.time < nowTime00) {
  104. this.show = true
  105. console.log(333)
  106. } else {
  107. console.log(444)
  108. this.show = false
  109. }
  110. }
  111. });
  112. } else {
  113. this.show = true
  114. }
  115. },
  116. handleGetPointsConfig(type) {
  117. kipGetPointsConfig().then(resp => {
  118. const result = resp;
  119. // codes,wxAuth,aliAuth
  120. console.log(111222, resp)
  121. this.pointsConfig = result
  122. if (result) {
  123. if (result && result.codes) {
  124. // codes,wxAuth,aliAuth
  125. this.pointsConfig = result
  126. console.log(111)
  127. if (!this.pointsConfig.wxAuth && this.pointsConfig.codes.indexOf('wxpay') != -1) {
  128. console.log(222)
  129. this.checkShowFlag()
  130. }
  131. } else {
  132. // this.$store.commit('setPointsModalFlag', false);
  133. if (result.code && result.code === '300000') {
  134. // this.checkoutLogin()
  135. } else {
  136. uni.showToast({
  137. icon: 'none',
  138. mask: true,
  139. duration: 2000,
  140. title: result.errorMessage || result.message || '出错了,请稍后再试'
  141. })
  142. }
  143. }
  144. } else {
  145. // this.$store.commit('setPointsModalFlag', false);
  146. if (resp.code && resp.code === '300000') {
  147. // this.checkoutLogin()
  148. } else {
  149. uni.showToast({
  150. icon: 'none',
  151. mask: true,
  152. duration: 2000,
  153. title: resp.message
  154. })
  155. }
  156. }
  157. }).catch(e => {
  158. // this.$store.commit('setPointsModalFlag', false);
  159. })
  160. },
  161. async toWxPointsAuth(type) {
  162. if (!type) {
  163. return
  164. }
  165. if (window.__wxjs_environment === 'miniprogram') {
  166. wx.miniProgram.navigateTo({
  167. "url": "/pages/accumulatePoints/selfServicePoints?redirect=1" // 去 login 页面 1 去登录
  168. })
  169. }
  170. if (isAlipayClient) {
  171. my?.navigateTo({
  172. "url": "/pages/accumulatePoints/selfServicePoints?redirect=1" // 去 login 页面 1 去登录
  173. })
  174. }
  175. // // mini 跳转
  176. // wx.miniProgram.redirectTo({
  177. // "url": "/pages/accumulatePoints/selfServicePoints?redirect=1" // 去 login 页面 1 去登录
  178. // })
  179. },
  180. }
  181. }
  182. </script>
  183. <style>
  184. .box {
  185. position: absolute;
  186. z-index: 10000;
  187. width: calc(100vw - 84px);
  188. padding: 8px 20px;
  189. height: 80px;
  190. left: 24px;
  191. border-radius: 4px;
  192. background: #000;
  193. }
  194. .box-text {
  195. color: #fff;
  196. display: flex;
  197. height: 100%;
  198. line-height: 80px;
  199. width: 100%;
  200. justify-content: space-between;
  201. }
  202. .box-text-left {
  203. font-size: 28px;
  204. line-height: 80px;
  205. height: 24px;
  206. }
  207. .box-text-right {
  208. display: flex;
  209. justify-content: center;
  210. font-size: 26px;
  211. line-height: 80px;
  212. height: 24px;
  213. }
  214. .box-text-right-icon {
  215. display: inline-block;
  216. margin-left: 5px;
  217. position: relative;
  218. top: -1px;
  219. }
  220. .box-text-right-icon-close {
  221. margin-left: 5px;
  222. }
  223. .box-text-right-btn {
  224. height: 46px;
  225. line-height: 46px;
  226. border-radius: 22px;
  227. padding: 0 18px;
  228. margin-top:17px;
  229. margin-right:10px;
  230. }
  231. </style>