产品库开发环境已调整好
This commit is contained in:
		@@ -24,8 +24,6 @@ export default {
 | 
			
		||||
    initDev() {
 | 
			
		||||
      let baseURL = 'http://192.168.1.87:9000'
 | 
			
		||||
      this.getConfig({baseURL})
 | 
			
		||||
      
 | 
			
		||||
      // this.$store.commit('login', 'bearer 88dd207a-dfe3-4f81-b9bd-e379de427d0b')
 | 
			
		||||
    },
 | 
			
		||||
    initConfig() {
 | 
			
		||||
      if (process.env.NODE_ENV == 'development') this.initDev()
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
import axios from 'axios'
 | 
			
		||||
import store from '../store'
 | 
			
		||||
import util from "./util";
 | 
			
		||||
 | 
			
		||||
let instance = axios.create({
 | 
			
		||||
  baseURL: process.env.NODE_ENV === "production" ? "/" : "/lan",
 | 
			
		||||
  timeout: 600000,
 | 
			
		||||
  withCredentials: true,
 | 
			
		||||
})
 | 
			
		||||
@@ -23,27 +23,7 @@ instance.interceptors.response.use(res => {
 | 
			
		||||
        return res.data
 | 
			
		||||
      } else if (res.data.code == 401) {
 | 
			
		||||
        store.commit("logout");
 | 
			
		||||
        let reg = new RegExp('.*code=(.+$)', "g")
 | 
			
		||||
        if (reg.test(location.search)) {
 | 
			
		||||
          let code = location.search.replace(reg, '$1')
 | 
			
		||||
          store.commit('bindAccount', {
 | 
			
		||||
            code, then: res => {
 | 
			
		||||
              store.commit("login", [res?.token_type, res?.access_token].join(" ").trim())
 | 
			
		||||
              location.href = location.href.replace('code=' + code, '')
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
        } else util.confirm("用户信息验证失效,是否要重新登录?").then(() => {
 | 
			
		||||
          store.commit('redirectCode')
 | 
			
		||||
          // let app = store.state.apps?.find(e => location.href.indexOf(e.path) > -1)
 | 
			
		||||
          // const goto = path => {
 | 
			
		||||
          //   location.href = location.origin + "/pages/loading?" + path
 | 
			
		||||
          // }
 | 
			
		||||
          // if (app) {
 | 
			
		||||
          //   goto(location.search + `&app=${app.key}`)
 | 
			
		||||
          // } else {
 | 
			
		||||
          //   goto(location.search + `#error`)
 | 
			
		||||
          // }
 | 
			
		||||
        }).catch(() => 0)
 | 
			
		||||
        uni.navigateTo({url: "/pages/login"})
 | 
			
		||||
      } else {
 | 
			
		||||
        console.error(res.data.msg || "请求失败!")
 | 
			
		||||
        return Promise.reject(res.data.msg)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ import mixin from './uview/libs/mixin/mixin';
 | 
			
		||||
Vue.config.productionTip = false;
 | 
			
		||||
Vue.prototype.$store = store;
 | 
			
		||||
//初始化接口工具类
 | 
			
		||||
axios.defaults.baseURL = store.state.baseURL;
 | 
			
		||||
Vue.prototype.$http = axios;
 | 
			
		||||
Vue.prototype.$cdn = 'https://cdn.cunwuyun.cn/dvcp/h5/';
 | 
			
		||||
Vue.prototype.imgHomeUrl = 'https://cdn.cunwuyun.cn/dvcp/h5/home/';
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "dv_cp_weixin",
 | 
			
		||||
  "description": "企业微信应用",
 | 
			
		||||
  "name": "dv-sass-app",
 | 
			
		||||
  "description": "企业微信应用库",
 | 
			
		||||
  "versionName": "1.0.0",
 | 
			
		||||
  "versionCode": "100",
 | 
			
		||||
  "transformPx": true,
 | 
			
		||||
@@ -25,7 +25,16 @@
 | 
			
		||||
    },
 | 
			
		||||
    "devServer": {
 | 
			
		||||
      "disableHostCheck": true,
 | 
			
		||||
      "port": "10323"
 | 
			
		||||
      "port": "10323",
 | 
			
		||||
      "proxy": {
 | 
			
		||||
        "/lan": {
 | 
			
		||||
          "target": "http://192.168.1.87:9000",
 | 
			
		||||
          "changeOrigin": true,
 | 
			
		||||
          "pathRewrite": {
 | 
			
		||||
            "^/lan": "/"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "optimization": {
 | 
			
		||||
      "preload": true,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="interview">
 | 
			
		||||
  <div class="AppInterview">
 | 
			
		||||
    <ai-top-fixed>
 | 
			
		||||
      <div flex>
 | 
			
		||||
        <ai-date placeholder="日期选择" mode="range" @change="handleDateSearch"/>
 | 
			
		||||
@@ -44,7 +44,8 @@ import AiDate from "../../components/AiDate";
 | 
			
		||||
import AiFixedBtn from "../../components/AiFixedBtn";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: "interview",
 | 
			
		||||
  name: "AppInterview",
 | 
			
		||||
  label: "调查走访",
 | 
			
		||||
  components: {AiFixedBtn, AiDate, AiImage, AiCard, AiTopFixed, AiSelect},
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
@@ -113,7 +114,7 @@ export default {
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
.interview {
 | 
			
		||||
.AppInterview {
 | 
			
		||||
  width: 100%;
 | 
			
		||||
  min-height: 100%;
 | 
			
		||||
  box-sizing: border-box;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,14 +4,11 @@
 | 
			
		||||
    <!--    <div class="iconfont iconfont-iconjuminxinxi"/>-->
 | 
			
		||||
    <!--    <div class="iconfont iconfont-iconLogo"/>-->
 | 
			
		||||
    <ai-result v-if="result.tips" v-bind="result"/>
 | 
			
		||||
    <template v-if="isDev">
 | 
			
		||||
      <input v-if="!!$route.query.code" class="codeText" :value="$route.query.code"/>
 | 
			
		||||
      <div class="codeBtn" @click="devGetCode">获取code</div>
 | 
			
		||||
      <div flex class="appsPane wrap">
 | 
			
		||||
        <b v-for="app in apps" :key="app.key" @tap="gotoApp(app.key)">{{ app.name }}</b>
 | 
			
		||||
      </div>
 | 
			
		||||
    </template>
 | 
			
		||||
 | 
			
		||||
    <input v-if="!!$route.query.code" class="codeText" :value="$route.query.code"/>
 | 
			
		||||
    <div class="codeBtn" @click="handleLogin">去登录</div>
 | 
			
		||||
    <div flex class="appsPane wrap">
 | 
			
		||||
      <b v-for="app in apps" :key="app.key" @tap="redirectTo(app.path)">{{ app.name }}</b>
 | 
			
		||||
    </div>
 | 
			
		||||
  </section>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
@@ -28,9 +25,6 @@ export default {
 | 
			
		||||
    ...mapState(['token', 'apps', 'openUser', 'user']),
 | 
			
		||||
    currentApp() {
 | 
			
		||||
      return this.apps.find(e => e.key == this.$route.query.app) || {}
 | 
			
		||||
    },
 | 
			
		||||
    isDev() {
 | 
			
		||||
      return this.$route.hash == "#dev"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
@@ -40,49 +34,20 @@ export default {
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    ...mapActions(['getToken', 'getAccount', 'agentSign', 'getUserInfo', 'getCode', 'closeAgent']),
 | 
			
		||||
    initAccess() {
 | 
			
		||||
      if (this.$route.hash == "#error" || this.isDev) {
 | 
			
		||||
        return Promise.resolve()
 | 
			
		||||
      } else if (this.$route.hash == "#form") {
 | 
			
		||||
        if (this.openUser?.openId || !!this.$route.query.preview) {
 | 
			
		||||
          this.openForm()
 | 
			
		||||
        } else if (this.$route.query?.code) {
 | 
			
		||||
          this.getToken(this.$route.query?.code)
 | 
			
		||||
          .then(() => this.getUserInfo())
 | 
			
		||||
          .then(() => this.openForm())
 | 
			
		||||
        } else this.getCode(location.href)
 | 
			
		||||
      } else if (this.token) {//获取账号信息
 | 
			
		||||
        return this.getAccount()
 | 
			
		||||
      } else if (this.$route.query?.code) {//获取token
 | 
			
		||||
        return this.getToken(this.$route.query?.code)
 | 
			
		||||
      } else {//获取应用配置
 | 
			
		||||
        this.getCode(location.href)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    openForm() {
 | 
			
		||||
      this.redirectTo("/askForm/askForm")
 | 
			
		||||
    },
 | 
			
		||||
    redirectTo(path) {
 | 
			
		||||
      let {query, hash} = this.$route
 | 
			
		||||
      delete query.app
 | 
			
		||||
      uni.redirectTo({
 | 
			
		||||
      uni.navigateTo({
 | 
			
		||||
        url: `/pages${path}`, success: () => {
 | 
			
		||||
          this.$router.push({query, hash})
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    gotoApp(app) {
 | 
			
		||||
      uni.reLaunch({url: '/pages/loading?app=' + app})
 | 
			
		||||
    },
 | 
			
		||||
    devGetCode() {
 | 
			
		||||
      this.getCode(location.origin + '/pages/loading#dev')
 | 
			
		||||
    handleLogin() {
 | 
			
		||||
      uni.navigateTo({url: "./login"})
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    uni.showLoading({
 | 
			
		||||
      title: "加载中"
 | 
			
		||||
    })
 | 
			
		||||
    uni.hideLoading()
 | 
			
		||||
    this.result = {
 | 
			
		||||
      tips: "欢迎进入开发应用",
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,79 +1,51 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <section class="login">
 | 
			
		||||
    <u-form :model="form" ref="loginForm" label-width="140">
 | 
			
		||||
      <u-form-item label="账号" prop="phone" :errory-type="['message']">
 | 
			
		||||
        <u-input v-model="form.phone" placeholder="请输入手机号"/>
 | 
			
		||||
      <u-form-item label="账号" prop="username">
 | 
			
		||||
        <u-input v-model="form.username" placeholder="请输入手机号"/>
 | 
			
		||||
      </u-form-item>
 | 
			
		||||
      <u-form-item label="验证码" prop="vcode">
 | 
			
		||||
        <u-input v-model="form.vcode" placeholder="请输入短信验证码"/>
 | 
			
		||||
        <u-verification-code ref="vcode" secords="60" @change="v=>tips=v"/>
 | 
			
		||||
        <div class="vcode" @tap="$u.debounce(getVCode)">{{ tips }}</div>
 | 
			
		||||
      <u-form-item label="密码" prop="password">
 | 
			
		||||
        <u-input type="password" v-model="form.password" placeholder="请输入密码"/>
 | 
			
		||||
      </u-form-item>
 | 
			
		||||
    </u-form>
 | 
			
		||||
    <div bottom>
 | 
			
		||||
      <u-button type="primary" @tap="handleLogin">绑定并登录</u-button>
 | 
			
		||||
      <u-button type="primary" @tap="handleLogin">登录</u-button>
 | 
			
		||||
    </div>
 | 
			
		||||
  </section>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import {mapActions, mapState} from "vuex";
 | 
			
		||||
import {mapActions, mapMutations} from "vuex";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: "login",
 | 
			
		||||
  inject: ['root'],
 | 
			
		||||
  computed: {
 | 
			
		||||
    ...mapState(['lastPage']),
 | 
			
		||||
    rules() {
 | 
			
		||||
      return {
 | 
			
		||||
        phone: [{required: true, message: "请选择分组"}],
 | 
			
		||||
        vcode: [{required: true, message: "请选择快捷回复类型"}],
 | 
			
		||||
        username: [{required: true, message: "请输入 手机号"}],
 | 
			
		||||
        password: [{required: true, message: "请输入 密码"}],
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      form: {},
 | 
			
		||||
      tips: ''
 | 
			
		||||
      form: {}
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    ...mapActions(['getCode']),
 | 
			
		||||
    getVCode() {
 | 
			
		||||
      if (this.form.phone) {
 | 
			
		||||
        this.$http.post("/admin/user/sendCode", null, {
 | 
			
		||||
          withoutToken: 1,
 | 
			
		||||
          params: {phone: this.form.phone}
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
          this.$u.toast("验证已发送!")
 | 
			
		||||
          this.$refs.vcode?.start()
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.$u.toast("请先填写手机号!")
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    ...mapActions(['getToken']),
 | 
			
		||||
    ...mapMutations(['login']),
 | 
			
		||||
    handleLogin() {
 | 
			
		||||
      this.$refs.loginForm.validate(v => {
 | 
			
		||||
        if (v) {
 | 
			
		||||
          let params = {
 | 
			
		||||
            ...this.form, code: this.$route.query?.code, then: res => {
 | 
			
		||||
              let last = uni.getStorageSync("lastApp")
 | 
			
		||||
              if (last) {
 | 
			
		||||
                this.$store.commit("login", [res?.token_type, res?.access_token].join(" ").trim())
 | 
			
		||||
                uni.removeStorageSync("lastApp")
 | 
			
		||||
                // this.root.getCode(location.origin + last)
 | 
			
		||||
                uni.reLaunch({url: "./loading?app=" + last})
 | 
			
		||||
              } else this.$u.toast("绑定成功,请重新打开应用页面!")
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          this.$store.commit("bindAccount", params)
 | 
			
		||||
          this.getToken(this.form).then(() => {
 | 
			
		||||
            uni.navigateBack({})
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    !this.$route.query?.code && this.getCode()
 | 
			
		||||
  },
 | 
			
		||||
  mounted() {
 | 
			
		||||
    this.$nextTick(() => this.$refs.loginForm?.setRules(this.rules))
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,12 @@ import Vue from 'vue'
 | 
			
		||||
import Vuex from 'vuex'
 | 
			
		||||
import perState from 'vuex-persistedstate'
 | 
			
		||||
import http from '../common/axios'
 | 
			
		||||
import CryptoJS from '../utils/crypto-js'
 | 
			
		||||
 | 
			
		||||
Vue.use(Vuex)
 | 
			
		||||
let agentSignURL = "", apiList = [], agentConfig = {},
 | 
			
		||||
    apps = [
 | 
			
		||||
      {name: '调查走访', key: "interview", path: '/interview/interview'},
 | 
			
		||||
      {name: '调查走访', key: "interview", path: '/interview/AppInterview'},
 | 
			
		||||
      {name: '工作去向', key: "whereabouts", path: '/whereabouts/whereabouts'},
 | 
			
		||||
      {name: '随手拍', key: "snapshot", path: '/snapshot/snapshot'},
 | 
			
		||||
      {name: '随心问', key: "casuallyask", path: '/casuallyask/casuallyask'},
 | 
			
		||||
@@ -179,21 +180,42 @@ const store = new Vuex.Store({
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  actions: {
 | 
			
		||||
    getToken(state, code) {
 | 
			
		||||
    getToken(state, params) {
 | 
			
		||||
      const encryptByDES = password => {
 | 
			
		||||
        let isIos = wx.getSystemInfoSync().system.toUpperCase === 'ios'
 | 
			
		||||
        let key = "thanks,villcloud"
 | 
			
		||||
        let iv = CryptoJS.enc.Latin1.parse(key)
 | 
			
		||||
        let encrypted = CryptoJS.AES.encrypt(password, iv, {
 | 
			
		||||
          iv: iv,
 | 
			
		||||
          mode: CryptoJS.mode.CBC,
 | 
			
		||||
          padding: CryptoJS.pad.ZeroPadding
 | 
			
		||||
        })
 | 
			
		||||
        if (isIos) {
 | 
			
		||||
          return encodeURIComponent(encrypted.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
          return encrypted.toString();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return new Promise((resolve, reject) => {
 | 
			
		||||
        http.post("/auth/wechatcp/token", {code}, {
 | 
			
		||||
        http.post("/auth/oauth/token", null, {
 | 
			
		||||
          withoutToken: true,
 | 
			
		||||
          params: {
 | 
			
		||||
            ...params, grant_type: 'password',
 | 
			
		||||
            password: encryptByDES(params.password)
 | 
			
		||||
          },
 | 
			
		||||
          headers: {
 | 
			
		||||
            Authorization: "Basic d2VjaGF0OndlY2hhdA=="
 | 
			
		||||
          }
 | 
			
		||||
        }).then(res => {
 | 
			
		||||
          if (res?.code == 1) {
 | 
			
		||||
            // 鉴权失败,需要重新绑定账号
 | 
			
		||||
          } else {
 | 
			
		||||
          if (res?.access_token) {
 | 
			
		||||
            state.commit("login", [res?.token_type, res?.access_token].join(" ").trim())
 | 
			
		||||
            resolve(state.dispatch("getAccount"))
 | 
			
		||||
            state.dispatch("getAccount")
 | 
			
		||||
            resolve()
 | 
			
		||||
          }
 | 
			
		||||
        }).catch(() => reject())
 | 
			
		||||
        }).catch(err => {
 | 
			
		||||
          uni.showToast({title: err, icon: 'none'})
 | 
			
		||||
          reject()
 | 
			
		||||
        })
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    getCode(store, url) {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,9 +6,7 @@
 | 
			
		||||
  <meta name="viewport"
 | 
			
		||||
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
 | 
			
		||||
  <meta name="format-detection" content="telephone=yes"/>
 | 
			
		||||
  <title>
 | 
			
		||||
    <%= htmlWebpackPlugin.options.title %>
 | 
			
		||||
  </title>
 | 
			
		||||
  <title>企微应用产品库</title>
 | 
			
		||||
  <!-- 正式发布的时候使用,开发期间不启用。↓ -->
 | 
			
		||||
  <!-- <script src="/h5/touch-emulator.js"></script>
 | 
			
		||||
<script>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6059
									
								
								src/utils/crypto-js.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6059
									
								
								src/utils/crypto-js.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user