浏览代码

静态页面

xcx 4 年前
父节点
当前提交
38dbf1ba64
共有 4 个文件被更改,包括 61 次插入2 次删除
  1. 42
    2
      src/pages/WoDe/ZhiFuBaoRenZheng/index.vue
  2. 10
    0
      src/pages/WoDe/ZhiFuBaoRenZheng/page.scss
  3. 5
    0
      src/store/user/index.js
  4. 4
    0
      src/util/Api.js

+ 42
- 2
src/pages/WoDe/ZhiFuBaoRenZheng/index.vue 查看文件

1
 <template>
1
 <template>
2
   <div class="Page">
2
   <div class="Page">
3
-    <MainPageContainer :ShowMainHeader="true" :MainHeaderTitle="`支付宝认证`" :ShowMainHeaderBack="true" :ShowMainHeaderMore="true" :MainHeaderMoreText="`保存`">
3
+    <MainPageContainer @UserInfoChange="UserInfoChange" :ShowMainHeader="true" :MainHeaderTitle="`支付宝认证`" :ShowMainHeaderBack="true" :ShowMainHeaderMore="true" :MainHeaderMoreText="`保存`">
4
       <div class="Container">
4
       <div class="Container">
5
-        <div class="Content">
5
+        <div class="Content" v-if="UserInfo !== null && UserInfo.isValidAli">
6
 
6
 
7
           <div>
7
           <div>
8
             <div class="Line flex-h">
8
             <div class="Line flex-h">
112
           </div>
112
           </div>
113
 
113
 
114
         </div>
114
         </div>
115
+        <div class="Content" v-if="UserInfo !== null && !UserInfo.isValidAli">
116
+          <a class="AliShouQuan centerLabel">支付宝授权</a>
117
+        </div>
115
       </div>
118
       </div>
116
     </MainPageContainer>
119
     </MainPageContainer>
117
   </div>
120
   </div>
119
 
122
 
120
 <script>
123
 <script>
121
 import MainPageContainer from '../../../components/common/MainPageContainer'
124
 import MainPageContainer from '../../../components/common/MainPageContainer'
125
+import { createNamespacedHelpers } from 'vuex'
126
+const { mapState: mapUserState, mapActions: mapUserActions } = createNamespacedHelpers('user')
122
 export default {
127
 export default {
123
   name: 'index',
128
   name: 'index',
124
   data () {
129
   data () {
125
     return {
130
     return {
131
+      Timer: null
126
     }
132
     }
127
   },
133
   },
128
   computed: {
134
   computed: {
135
+    ...mapUserState({
136
+      CurrentShopInfo: x => x.CurrentShopInfo,
137
+      UserInfo: x => x.UserInfo
138
+    })
129
   },
139
   },
130
   components: {
140
   components: {
131
     MainPageContainer
141
     MainPageContainer
132
   },
142
   },
133
   created () {
143
   created () {
144
+    if (this.UserInfo !== null) {
145
+      this.UserInfoChange()
146
+    }
134
   },
147
   },
135
   mounted () {
148
   mounted () {
136
     this.$nextTick(() => {
149
     this.$nextTick(() => {
137
     })
150
     })
138
   },
151
   },
139
   methods: {
152
   methods: {
153
+    ...mapUserActions([
154
+      'GetAliAppId'
155
+    ]),
156
+    UserInfoChange () {
157
+      if (this.UserInfo !== null && !this.UserInfo.isValidAli) {
158
+        let HtmlHead = document.getElementsByTagName('head')[0]
159
+        let Script = document.createElement('script')
160
+        Script.src = 'https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js'
161
+        HtmlHead.appendChild(Script)
162
+        window.clearInterval(this.Timer)
163
+        this.Timer = window.setInterval(() => {
164
+          if (window.ap) {
165
+            window.clearInterval(this.Timer)
166
+            this.GetAliAppId().then((res) => {
167
+              document.getElementsByClassName('AliShouQuan')[0].addEventListener('click', () => {
168
+                window.ap.getAuthCode({
169
+                  appId: res.data.data,
170
+                  scopes: ['auth_base']
171
+                }, (subRes) => {
172
+                  console.log(subRes)
173
+                })
174
+              })
175
+            })
176
+          }
177
+        }, 100)
178
+      }
179
+    },
140
     Refresh (done) { // 页面下拉刷新
180
     Refresh (done) { // 页面下拉刷新
141
       window.setTimeout(() => {
181
       window.setTimeout(() => {
142
         done()
182
         done()

+ 10
- 0
src/pages/WoDe/ZhiFuBaoRenZheng/page.scss 查看文件

13
       position: relative;
13
       position: relative;
14
       overflow: hidden;
14
       overflow: hidden;
15
       padding-bottom: 0.2rem;
15
       padding-bottom: 0.2rem;
16
+      min-height: 100%;
17
+      > .AliShouQuan {
18
+        font-size: 0.14rem;
19
+        line-height: 0.4rem;
20
+        width: 80%;
21
+        text-align: center;
22
+        background: #d91e36;
23
+        color: #fff;
24
+        border-radius: 0.06rem;
25
+      }
16
       > div {
26
       > div {
17
         padding: 0 0.15rem;
27
         padding: 0 0.15rem;
18
         background: #fff;
28
         background: #fff;

+ 5
- 0
src/store/user/index.js 查看文件

79
     }
79
     }
80
   },
80
   },
81
   actions: {
81
   actions: {
82
+    GetAliAppId (context, payload) { // 获取阿里pay id
83
+      return new Promise((resolve, reject) => {
84
+        ToolClass.Axios(resolve, reject, Api.GetAliAppId, context, payload, 1000)
85
+      })
86
+    },
82
     ShopValid (context, payload) { // 店铺认证
87
     ShopValid (context, payload) { // 店铺认证
83
       return new Promise((resolve, reject) => {
88
       return new Promise((resolve, reject) => {
84
         ToolClass.Axios(resolve, reject, Api.ShopValid, context, payload, 1000)
89
         ToolClass.Axios(resolve, reject, Api.ShopValid, context, payload, 1000)

+ 4
- 0
src/util/Api.js 查看文件

2
 const prefix = process.env.NODE_ENV === 'production' ? '/api' : '/api'
2
 const prefix = process.env.NODE_ENV === 'production' ? '/api' : '/api'
3
 
3
 
4
 const $api = {
4
 const $api = {
5
+  GetAliAppId: { // 获取阿里pay id
6
+    method: 'get',
7
+    url: `${prefix}/shop/alipay/appid`
8
+  },
5
   ShopValid: { // 店铺认证
9
   ShopValid: { // 店铺认证
6
     method: 'put',
10
     method: 'put',
7
     url: `${prefix}/app/shop/valid`
11
     url: `${prefix}/app/shop/valid`