wx-points-auth.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. isLogin: (state) => state.isLogin,
  59. }),
  60. pointsModalFlag() {
  61. return this.$store.state.pointsModalFlag
  62. }
  63. },
  64. mounted() {
  65. // this.checkShowFlag()
  66. this.handleGetPointsConfig('init')
  67. },
  68. methods: {
  69. checkoutLogin() {
  70. this.toWxPointsAuth()
  71. },
  72. close() {
  73. this.show = false
  74. var arr_lbs_end_time = []
  75. if (uni.getStorageSync('lbs_end_time')) {
  76. arr_lbs_end_time = uni.getStorageSync('lbs_end_time')
  77. arr_lbs_end_time = arr_lbs_end_time.filter(item => item.lbsId !== this.$store.state?.lbsId);
  78. console.log('del_arr_lbs_end_time:::', arr_lbs_end_time)
  79. arr_lbs_end_time.push({
  80. lbsId: this.$store.state?.lbsId,
  81. time: new Date().getTime()
  82. })
  83. uni.setStorageSync("lbs_end_time", arr_lbs_end_time)
  84. uni.setStorageSync("ceshi", 4534534534534534534)
  85. } else {
  86. arr_lbs_end_time.push({
  87. lbsId: this.$store.state?.lbsId,
  88. time: new Date().getTime()
  89. })
  90. uni.setStorageSync("lbs_end_time", arr_lbs_end_time)
  91. }
  92. },
  93. checkShowFlag() {
  94. const nowTime = new Date()
  95. const nowTime00 = new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  96. var arr_lbs_end_time = [];
  97. if (uni.getStorageSync('lbs_end_time')) {
  98. console.log(555)
  99. arr_lbs_end_time = uni.getStorageSync('lbs_end_time')
  100. console.log(666)
  101. console.log('arr_lbs_end_time::', uni.getStorageSync('lbs_end_time'))
  102. const arr_lbsId = arr_lbs_end_time.filter(element => {
  103. return element.lbsId === this.$store.state?.lbsId
  104. })
  105. if (arr_lbsId.length > 0) {
  106. console.log(777)
  107. if (arr_lbsId[arr_lbsId.length - 1].time < nowTime00) {
  108. this.show = true
  109. console.log(333)
  110. } else {
  111. console.log(444)
  112. this.show = false
  113. }
  114. } else {
  115. this.show = true
  116. }
  117. console.log('arr_lbsId:::', arr_lbsId, this.$store.state?.lbsId)
  118. // arr_lbs_end_time.forEach(element => {
  119. // if (this.$store.state?.lbsId === element.lbsId) {
  120. // console.log(777)
  121. // if (element.time < nowTime00) {
  122. // this.show = true
  123. // console.log(333)
  124. // } else {
  125. // console.log(444)
  126. // this.show = false
  127. // }
  128. // } else {
  129. // }
  130. // });
  131. } else {
  132. this.show = true
  133. }
  134. },
  135. handleGetPointsConfig(type) {
  136. // if(this.isLogin === 'loginDenied') return
  137. kipGetPointsConfig().then(resp => {
  138. const result = resp;
  139. // codes,wxAuth,aliAuth
  140. console.log(111222, resp)
  141. this.pointsConfig = result
  142. if (result) {
  143. if (result && result.codes) {
  144. // codes,wxAuth,aliAuth
  145. this.pointsConfig = result
  146. console.log(111)
  147. if (!this.pointsConfig.wxAuth && this.pointsConfig.codes.indexOf('wxpay') != -1) {
  148. console.log(222)
  149. this.checkShowFlag()
  150. }
  151. } else {
  152. // this.$store.commit('setPointsModalFlag', false);
  153. if (result.code && result.code === '300000') {
  154. // this.checkoutLogin()
  155. } else {
  156. // console.log(222222)
  157. // 非南昌办公楼展示自助积分功能接口请求出错
  158. if (this.$store.state?.lbsId !== '8a84834088f11119018949444636000c' && this.$store.state?.lbsId !== '8a88817a8a629b5f018a838a0f6e001f') {
  159. uni.showToast({
  160. icon: 'none',
  161. mask: true,
  162. duration: 2000,
  163. title: result.errorMessage || result.message || '出错了,请稍后再试'
  164. })
  165. }
  166. }
  167. }
  168. } else {
  169. // this.$store.commit('setPointsModalFlag', false);
  170. if (resp.code && resp.code === '300000') {
  171. // this.checkoutLogin()
  172. } else {
  173. uni.showToast({
  174. icon: 'none',
  175. mask: true,
  176. duration: 2000,
  177. title: resp.message
  178. })
  179. }
  180. }
  181. }).catch(e => {
  182. // this.$store.commit('setPointsModalFlag', false);
  183. })
  184. },
  185. async toWxPointsAuth(type) {
  186. if (!type) {
  187. return
  188. }
  189. if (window.__wxjs_environment === 'miniprogram') {
  190. wx.miniProgram.navigateTo({
  191. "url": "/pages/accumulatePoints/selfServicePoints?redirect=1&backUrl=pages/package-parkingFee/parkingFeeWebView" // 去 login 页面 1 去登录
  192. })
  193. }
  194. if (window.isAlipayClient) {
  195. my?.navigateTo({
  196. "url": "/pages/accumulatePoints/selfServicePoints?redirect=1" // 去 login 页面 1 去登录
  197. })
  198. }
  199. // // mini 跳转
  200. // wx.miniProgram.redirectTo({
  201. // "url": "/pages/accumulatePoints/selfServicePoints?redirect=1" // 去 login 页面 1 去登录
  202. // })
  203. },
  204. }
  205. }
  206. </script>
  207. <style scoped>
  208. .box {
  209. position: absolute;
  210. z-index: 1000;
  211. width: calc(100vw - 84px);
  212. padding: 8px 20px;
  213. height: 80px;
  214. left: 24px;
  215. border-radius: 6px;
  216. background: #000;
  217. }
  218. .box-text {
  219. color: #fff;
  220. display: flex;
  221. height: 100%;
  222. line-height: 80px;
  223. width: 100%;
  224. justify-content: space-between;
  225. }
  226. .box-text-left {
  227. font-size: 28px;
  228. line-height: 80px;
  229. height: 24px;
  230. }
  231. .box-text-right {
  232. display: flex;
  233. justify-content: center;
  234. font-size: 26px;
  235. line-height: 80px;
  236. height: 24px;
  237. }
  238. .box-text-right-icon {
  239. display: inline-block;
  240. margin-left: 5px;
  241. position: relative;
  242. top: -1px;
  243. }
  244. .box-text-right-icon-close {
  245. margin-left: 5px;
  246. }
  247. .box-text-right-btn {
  248. height: 46px;
  249. line-height: 46px;
  250. border-radius: 22px;
  251. padding: 0 18px;
  252. margin-top:17px;
  253. margin-right:10px;
  254. }
  255. </style>