Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/views/system/profile/userProfile.vue
hyf 3 vuotta sitten
vanhempi
commit
519ccb38e1
1 muutettua tiedostoa jossa 39 lisäystä ja 30 poistoa
  1. 39 30
      src/views/system/profile/userProfile.vue

+ 39 - 30
src/views/system/profile/userProfile.vue

@@ -14,8 +14,7 @@
 
             <div class="box-center">
               <div class="user-name text-center">
-                <i class="el-icon-user" /> {{ viewData.accountName }}
-                <span v-if="viewData.accountStaffNo">[{{ viewData.accountStaffNo }}]</span>
+                <i class="el-icon-user" /> {{ viewData.accountName }} [{{ viewData.accountStaffNo }}]
               </div>
               <div class="user-phone text-center text-muted">
                 <i class="el-icon-mobile-phone" /> {{ viewData.accountPhone }}
@@ -51,7 +50,7 @@
                         :width="200"
                         :height="200"
                         field="file"
-                        url="/upload/file"
+                        url="/admin/uploadFile"
                         @close="cropperClose"
                         @crop-upload-success="cropSuccess"
                         @crop-upload-fail="cropFailed"
@@ -99,6 +98,9 @@
                     <el-button type="primary" @click="submitForm('passForm')">更新</el-button>
                   </div>
                 </el-tab-pane>
+                <el-tab-pane label="微信绑定" name="wx">
+                  <div id="qrcodetemplate" ref="qrcodetemplate" style="margin: 5px 0;" />
+                </el-tab-pane>
               </el-tabs>
             </vuescroll>
           </div>
@@ -108,12 +110,13 @@
   </div>
 </template>
 <script>
-
-import { getUserProfile, updateUserProfile } from '@/api'
+import { serverUrl, devServerUrl } from '@/settings'
+import { getUserProfile, updateUserProfile } from '@/api/index'
 import { updatePassword } from '@/api/system/userApi'
 import { mapGetters } from 'vuex'
 import vuescroll from 'vuescroll'
 import ImageCropper from '@/components/ImageCropper/index'
+import QRCode from 'qrcodejs2'
 export default {
   name: 'UserProfile',
   components: {
@@ -211,17 +214,32 @@ export default {
     cropperClose() {
       this.imageCropperShow = false
     },
-
+    drawQrcode() {
+      const ocId = this.userData.ocId
+      const userId = this.userData.userId
+
+      const baseURL = process.env.NODE_ENV === 'development' ? devServerUrl : serverUrl
+      const url = baseURL + '/wx/auth/' + ocId + '/' + userId
+      if (!url) {
+        this.$message.error('没有生产二维码的参数')
+        return
+      }
+      this.$nextTick(() => {
+        this.$refs.qrcodetemplate.innerHTML = ''
+        new QRCode('qrcodetemplate', {
+          width: 200,
+          height: 200,
+          text: url.toString()
+        })
+      })
+    },
     getData() {
       getUserProfile().then((resp) => {
-        const { code, data, msg } = resp
-        if (code === 200) {
-          this.viewData = JSON.parse(JSON.stringify(data))
-          this.basicData = data
-          this.passData.accountId = data.accountId
-        } else {
-          this.$message.error(msg)
-        }
+        const { data } = resp
+        this.viewData = JSON.parse(JSON.stringify(data))
+        this.basicData = data
+        this.passData.accountId = data.accountId
+        this.drawQrcode()
       }).catch((error) => {
         console.log(error)
       })
@@ -233,27 +251,18 @@ export default {
         if (valid) {
           if (formName === 'basicForm') {
             updateUserProfile(this.basicData).then((resp) => {
-              const { code, msg } = resp
-              if (code === 200) {
-                this.userData.userAvatar = this.basicData.accountAvatar
-                this.userData.userName = this.basicData.accountName
-                this.$store.dispatch('user/updateUserData', this.userData)
-                this.$message.success(msg)
-                this.getData()
-              } else {
-                this.$message.error(msg)
-              }
+              const { msg } = resp
+              this.userData.userAvatar = this.basicData.accountAvatar
+              this.userData.userName = this.basicData.accountName
+              this.$store.dispatch('user/updateUserData', this.userData)
+              this.$message.success(msg)
+              this.getData()
             }).catch((error) => {
               console.log(error)
             })
           } else {
             updatePassword(this.passData).then((resp) => {
-              const { code } = resp
-              if (code === 200) {
-                this.$message.success('密码更改成功!')
-              } else {
-                this.$message.error('密码更改失败!')
-              }
+              this.$message.success('密码更改成功!')
             }).catch((error) => {
               console.log(error)
             })