From b15a83329e33a954f41c9558b58aa1a64332c46b Mon Sep 17 00:00:00 2001 From: Mr.Shi <1878285526@qq.com> Date: 星期五, 11 八月 2023 18:04:51 +0800 Subject: [PATCH] 标准版h5 --- h5_standard/src/views/LogInAgain.vue | 2 h5_standard/src/views/wxLogin.vue | 68 +++ h5_standard/src/router/module/needToBeDealtWith/index.ts | 18 h5_standard/src/router/module/productionInspection/index.ts | 20 h5_standard/src/views/productionInspection/manualInspection2.vue | 402 +++++++++++++++++++ h5_standard/package.json | 5 h5_standard/.env.development | 4 h5_standard/package-lock.json | 37 + h5_standard/src/apis/index.ts | 18 h5_standard/src/views/productionInspection/manualInspection1.vue | 402 +++++++++++++++++++ h5_standard/src/views/productionInspection/manualInspection.vue | 8 h5_standard/public/redirect.html | 21 + h5_standard/src/views/needToBeDealtWith/addWarehousing.vue | 18 h5_standard/src/views/needToBeDealtWith/outbound.vue | 18 h5_standard/src/utils/utils.ts | 39 + h5_standard/src/utils/wechat.js | 144 ++++++ 16 files changed, 1,213 insertions(+), 11 deletions(-) diff --git a/h5_standard/.env.development b/h5_standard/.env.development index 5d2be80..9f9c1d8 100644 --- a/h5_standard/.env.development +++ b/h5_standard/.env.development @@ -14,9 +14,9 @@ # 浠诲悍鏈湴 -# VUE_APP_API = 'http://192.168.0.15:10021/' +VUE_APP_API = 'http://192.168.0.15:10021/' -VUE_APP_API = 'https://dmtest.ahapp.net/doumeeplant_api/' +# VUE_APP_API = 'https://dmtest.ahapp.net/doumeeplant_api/' # VUE_APP_API = 'http://192.168.0.13:10012/' diff --git a/h5_standard/package-lock.json b/h5_standard/package-lock.json index e6504d1..fad2d71 100644 --- a/h5_standard/package-lock.json +++ b/h5_standard/package-lock.json @@ -11,6 +11,7 @@ "axios": "^0.27.2", "dingtalk-jsapi": "^2.13.92", "echarts": "^4.8.0", + "js-sha1": "^0.6.0", "jsqr": "^1.4.0", "lib-flexible": "^0.3.2", "mitt": "^3.0.0", @@ -26,10 +27,12 @@ "vue": "^3.2.13", "vue-pdf-embed": "^1.1.4", "vue-router": "^4.0.3", - "vuex": "^4.0.0" + "vuex": "^4.0.0", + "weixin-js-sdk": "^1.6.0" }, "devDependencies": { "@types/echarts": "^4.9.15", + "@types/js-sha1": "^0.6.0", "@vue/cli-plugin-router": "~5.0.0", "@vue/cli-plugin-typescript": "~5.0.0", "@vue/cli-plugin-vuex": "~5.0.0", @@ -857,6 +860,12 @@ "dependencies": { "@types/node": "*" } + }, + "node_modules/@types/js-sha1": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/js-sha1/-/js-sha1-0.6.0.tgz", + "integrity": "sha512-TBJguE0wDNgtAwL7TpjzPbj5Sz5fsIuTQbgyXDJ7nV1eExhE/kd3YNS/q6JSiPAdElcFoKY3zlSifzjb/vO6xw==", + "dev": true }, "node_modules/@types/json-schema": { "version": "7.0.11", @@ -5101,6 +5110,11 @@ "engines": { "node": ">=0.6.0" } + }, + "node_modules/js-sha1": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/js-sha1/-/js-sha1-0.6.0.tgz", + "integrity": "sha512-01gwBFreYydzmU9BmZxpVk6svJJHrVxEN3IOiGl6VO93bVKYETJ0sIth6DASI6mIFdt7NmfX9UiByRzsYHGU9w==" }, "node_modules/js-tokens": { "version": "4.0.0", @@ -9687,6 +9701,11 @@ "node": ">=0.8.0" } }, + "node_modules/weixin-js-sdk": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/weixin-js-sdk/-/weixin-js-sdk-1.6.0.tgz", + "integrity": "sha512-3IYQH7aalJGFJrwdT3epvTdR1MboMiH7vIZ5BRL2eYOJ12BNah7csoMkmSZzkq1+l92sSq29XdTCVjCJoK2sBQ==" + }, "node_modules/whatwg-fetch": { "version": "3.6.2", "resolved": "https://registry.npmmirror.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", @@ -10568,6 +10587,12 @@ "requires": { "@types/node": "*" } + }, + "@types/js-sha1": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/js-sha1/-/js-sha1-0.6.0.tgz", + "integrity": "sha512-TBJguE0wDNgtAwL7TpjzPbj5Sz5fsIuTQbgyXDJ7nV1eExhE/kd3YNS/q6JSiPAdElcFoKY3zlSifzjb/vO6xw==", + "dev": true }, "@types/json-schema": { "version": "7.0.11", @@ -13822,6 +13847,11 @@ "resolved": "https://registry.npmmirror.com/js-message/-/js-message-1.0.7.tgz", "integrity": "sha512-efJLHhLjIyKRewNS9EGZ4UpI8NguuL6fKkhRxVuMmrGV2xN/0APGdQYwLFky5w9naebSZ0OwAGp0G6/2Cg90rA==", "dev": true + }, + "js-sha1": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/js-sha1/-/js-sha1-0.6.0.tgz", + "integrity": "sha512-01gwBFreYydzmU9BmZxpVk6svJJHrVxEN3IOiGl6VO93bVKYETJ0sIth6DASI6mIFdt7NmfX9UiByRzsYHGU9w==" }, "js-tokens": { "version": "4.0.0", @@ -17233,6 +17263,11 @@ "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", "dev": true }, + "weixin-js-sdk": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/weixin-js-sdk/-/weixin-js-sdk-1.6.0.tgz", + "integrity": "sha512-3IYQH7aalJGFJrwdT3epvTdR1MboMiH7vIZ5BRL2eYOJ12BNah7csoMkmSZzkq1+l92sSq29XdTCVjCJoK2sBQ==" + }, "whatwg-fetch": { "version": "3.6.2", "resolved": "https://registry.npmmirror.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", diff --git a/h5_standard/package.json b/h5_standard/package.json index 1ba987e..f343fe0 100644 --- a/h5_standard/package.json +++ b/h5_standard/package.json @@ -10,6 +10,7 @@ "axios": "^0.27.2", "dingtalk-jsapi": "^2.13.92", "echarts": "^4.8.0", + "js-sha1": "^0.6.0", "jsqr": "^1.4.0", "lib-flexible": "^0.3.2", "mitt": "^3.0.0", @@ -25,10 +26,12 @@ "vue": "^3.2.13", "vue-pdf-embed": "^1.1.4", "vue-router": "^4.0.3", - "vuex": "^4.0.0" + "vuex": "^4.0.0", + "weixin-js-sdk": "^1.6.0" }, "devDependencies": { "@types/echarts": "^4.9.15", + "@types/js-sha1": "^0.6.0", "@vue/cli-plugin-router": "~5.0.0", "@vue/cli-plugin-typescript": "~5.0.0", "@vue/cli-plugin-vuex": "~5.0.0", diff --git a/h5_standard/public/redirect.html b/h5_standard/public/redirect.html new file mode 100644 index 0000000..79d3125 --- /dev/null +++ b/h5_standard/public/redirect.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title></title> +</head> +<body> +<script> + var url = window.location.href + if (url.indexOf('?code') === -1) { + let query = url.split('?')[1] + let tempUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4d7c10bdec51942b&redirect_uri=https://dmtest.ahapp.net/doumeeplant_h5/redirect.html&response_type=code&scope=snsapi_base&state=#wechat_redirect` + window.location.replace(tempUrl) + } else { + var code = url.substring(url.indexOf('?') + 6, url.indexOf('&')) + let href1 = `https://dmtest.ahapp.net/doumeeplant_h5/#/wxLogin?code=${code}` + window.location.replace(href1) + } +</script> +</body> +</html> diff --git a/h5_standard/src/apis/index.ts b/h5_standard/src/apis/index.ts index dd7739e..9a34f2b 100644 --- a/h5_standard/src/apis/index.ts +++ b/h5_standard/src/apis/index.ts @@ -11,6 +11,24 @@ }) } +// 鑾峰彇寰俊openId +export function wxLogin(params: any): Promise<any> { + return httpRequest({ + url: '/system/wxLogin', + method: 'get', + params + }) +} + +// 寰俊绔櫥褰� +export function wxAccountLogin(data: any): Promise<any> { + return httpRequest({ + url: '/system/wxAccountLogin', + method: 'post', + data + }) +} + // 鑾峰彇浼佷笟id export function getDingdingCorpId(companyId: any): Promise<any> { return httpRequest({ diff --git a/h5_standard/src/router/module/needToBeDealtWith/index.ts b/h5_standard/src/router/module/needToBeDealtWith/index.ts index 2f77f60..d17bcd1 100644 --- a/h5_standard/src/router/module/needToBeDealtWith/index.ts +++ b/h5_standard/src/router/module/needToBeDealtWith/index.ts @@ -26,6 +26,24 @@ component: () => import('@/views/needToBeDealtWith/warehousing.vue') }, { + path: '/needToBeDealtWith/outbound', + name: 'outbound', + meta: { + title: '鍑哄簱', + keepAlive: false + }, + component: () => import('@/views/needToBeDealtWith/outbound.vue') + }, + { + path: '/needToBeDealtWith/addWarehousing', + name: 'addWarehousing', + meta: { + title: '鍏ュ簱', + keepAlive: false + }, + component: () => import('@/views/needToBeDealtWith/addWarehousing.vue') + }, + { path: '/needToBeDealtWith/codeScanningWarehousing', name: 'codeScanningWarehousing', meta: { diff --git a/h5_standard/src/router/module/productionInspection/index.ts b/h5_standard/src/router/module/productionInspection/index.ts index 93199a5..9c29730 100644 --- a/h5_standard/src/router/module/productionInspection/index.ts +++ b/h5_standard/src/router/module/productionInspection/index.ts @@ -74,12 +74,30 @@ path: '/productionInspection/manualInspection', name: 'manualInspection', meta: { - title: '鎵嬪姩妫�楠�', + title: '宸$嚎', keepAlive: true }, component: () => import('@/views/productionInspection/manualInspection.vue') }, { + path: '/productionInspection/manualInspection1', + name: 'manualInspection1', + meta: { + title: '宸℃', + keepAlive: true + }, + component: () => import('@/views/productionInspection/manualInspection1.vue') + }, + { + path: '/productionInspection/manualInspection2', + name: 'manualInspection2', + meta: { + title: '瀹屽伐妫�', + keepAlive: true + }, + component: () => import('@/views/productionInspection/manualInspection2.vue') + }, + { path: '/productionInspection/selectWorkOrder', name: 'selectWorkOrder', meta: { diff --git a/h5_standard/src/utils/utils.ts b/h5_standard/src/utils/utils.ts index 83854d7..d04a906 100644 --- a/h5_standard/src/utils/utils.ts +++ b/h5_standard/src/utils/utils.ts @@ -1,6 +1,45 @@ import * as dd from 'dingtalk-jsapi' +import sha1 from 'js-sha1' import store from '@/store' +/** + * 鑾峰彇褰撳墠鏃堕棿 鏃堕棿鎴� + * @returns {number} + */ +export function getTimestamp () { + return new Date().getTime() +} + +/** + * 鑾峰彇闅忔満瀛楃涓� + * @param {number} len 鍙寚瀹氶暱搴� + * @returns {string} + */ +export function randomString (len: number): string { + len = len || 32 + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678' + let maxPos = $chars.length + let pwd = '' + for (let i = 0; i < len; i++) { + pwd += $chars.charAt(Math.floor(Math.random() * maxPos)) + } + return pwd +} + +/** + * 鎷兼帴绛惧悕瀛楃涓� + * @param {string} ticket 閫氳繃access_token鑾峰彇鐨刯sapi_ticket + * @param {string} noncestr 鑷繁鐢熸垚鐨勯殢鏈哄瓧绗︿覆 + * @param {string} timestamp 鐢熸垚绛惧悕鏃剁殑鏃堕棿鎴� + * @param {string} urlLink url鍦板潃鑾峰彇code + * @param {string} return {*} + */ +export function getSignature (ticket: String, noncestr: String, timestamp: String, urlLink: String): String { + let url = urlLink + let jsapi_ticket = `jsapi_ticket=${ticket}&noncestr=${noncestr}×tamp=${timestamp}&url=${url}` + return sha1(jsapi_ticket) +} + /*** * phoneRegular: 鎵嬫満鍙烽獙璇� * mailboxRegular: 閭楠岃瘉 diff --git a/h5_standard/src/utils/wechat.js b/h5_standard/src/utils/wechat.js new file mode 100644 index 0000000..3f9daf5 --- /dev/null +++ b/h5_standard/src/utils/wechat.js @@ -0,0 +1,144 @@ +import wx from 'weixin-js-sdk' +import { Toast } from 'vant' +import { getTimestamp, randomString, getSignature } from './utils.ts' + +class AuthWechat { + + /** + * 鑾峰彇娴忚鍣ㄥ湴鍧� + * */ + signLink() { + if (typeof window.entryUrl === 'undefined' || window.entryUrl === '') { + window.entryUrl = document.location.href + } + let url = /(Android)/i.test(navigator.userAgent) ? document.location.href : window.entryUrl; + return url.split('#')[0] + } + + /** + * 褰撳墠鏄惁鏄井淇$幆澧� + * */ + isWeixin() { + return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1; + } + + /** + * 鍒濆鍖� + * */ + wechat(ticket) { + if (!this.isWeixin()) { + return Toast.fail('褰撳墠涓嶆槸寰俊鐜'); + } + + return new Promise((resolve, reject) => { + let url = this.signLink() + let timestamp = getTimestamp() + let nonceStr = randomString() + let signature = getSignature(ticket, nonceStr, timestamp, url) + + wx.config({ + debug: false, // 寮�鍚皟璇曟ā寮�,璋冪敤鐨勬墍鏈塧pi鐨勮繑鍥炲�间細鍦ㄥ鎴风alert鍑烘潵锛岃嫢瑕佹煡鐪嬩紶鍏ョ殑鍙傛暟锛屽彲浠ュ湪pc绔墦寮�锛屽弬鏁颁俊鎭細閫氳繃log鎵撳嚭锛屼粎鍦╬c绔椂鎵嶄細鎵撳嵃銆� + appId: process.env.VUE_APP_APPID, // 蹇呭~锛屽叕浼楀彿鐨勫敮涓�鏍囪瘑 + timestamp, // 蹇呭~锛岀敓鎴愮鍚嶇殑鏃堕棿鎴� + nonceStr, // 蹇呭~锛岀敓鎴愮鍚嶇殑闅忔満涓� + signature, // 蹇呭~锛岀鍚� + jsApiList: [ + 'updateAppMessageShareData', // 鑷畾涔夆�滃垎浜粰鏈嬪弸鈥濆強鈥滃垎浜埌QQ鈥濇寜閽殑鍒嗕韩鍐呭 + 'updateTimelineShareData', // 鑷畾涔夆�滃垎浜埌鏈嬪弸鍦堚�濆強鈥滃垎浜埌QQ绌洪棿鈥濇寜閽殑鍒嗕韩鍐呭锛�1.4.0锛� + 'closeWindow', //鍏抽棴褰撳墠缃戦〉绐楀彛鎺ュ彛 + 'chooseWXPay' + ] + }) + wx.ready(res => { + // 寰俊SDK鍑嗗灏辩华鍚庢墽琛岀殑鍥炶皟銆� + // console.log('wx.ready',res); + resolve(wx, res) + }) + wx.error(err => { + // console.log('wx.error',err) + reject(wx, err) + }) + }) + } + + /** + * 寰俊鍒嗕韩 + * @param {object} shareObj 鍒嗕韩鍐呭瀵硅薄 + * */ + wxShare(shareObj) { + if (!this.isWeixin()) { + return Toast.fail('褰撳墠涓嶆槸寰俊鐜'); + } + console.log('鍒嗕韩', shareObj) + let norShare = new Promise((resolve, reject) => { + wx.ready(() => { + wx.updateAppMessageShareData({ + title: shareObj.title, // 鍒嗕韩鏍囬 + desc: shareObj.desc, // 鍒嗕韩鎻忚堪 + link: shareObj.link, // 鍒嗕韩閾炬帴锛岃閾炬帴鍩熷悕鎴栬矾寰勫繀椤讳笌褰撳墠椤甸潰瀵瑰簲鐨勫叕浼楀彿 JS 瀹夊叏鍩熷悕涓�鑷� + imgUrl: shareObj.imgUrl, // 鍒嗕韩鍥炬爣 + success: function () { + resolve('鎴愬姛浜�') + }, + fail: function (res) { + console.log('濂藉弸鍒嗕韩 澶辫触', res); + alert('fail:' + JSON.stringify(res)); + reject(JSON.stringify(res)) + } + }) + }) + }) + let friendShare = new Promise((resolve, reject) => { + wx.ready(() => { + wx.updateTimelineShareData({ + title: shareObj.title, // 鍒嗕韩鏍囬 + desc: shareObj.desc, // 鍒嗕韩鎻忚堪 + link: shareObj.link, // 鍒嗕韩閾炬帴锛岃閾炬帴鍩熷悕鎴栬矾寰勫繀椤讳笌褰撳墠椤甸潰瀵瑰簲鐨勫叕浼楀彿 JS 瀹夊叏鍩熷悕涓�鑷� + imgUrl: shareObj.imgUrl, // 鍒嗕韩鍥炬爣 + success: function () { + resolve('鎴愬姛浜�') + }, + fail: function (res) { + console.log('鏈嬪弸鍦堝垎浜� 澶辫触', res); + alert('fail:' + JSON.stringify(res)); + reject(JSON.stringify(res)) + } + }) + }) + }) + return Promise.all([norShare, friendShare]) + } + + wxPay(response) { + if (!this.isWeixin()) { + return Toast.fail('褰撳墠涓嶆槸寰俊鐜'); + } + console.log('鏀粯', response); + return new Promise((resolve, reject) => { + wx.chooseWXPay({ + appId: response.appId, + timestamp: response.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴筹紝娉ㄦ剰寰俊 jssdk 涓殑鎵�鏈変娇鐢� timestamp 瀛楁鍧囦负灏忓啓銆備絾鏈�鏂扮増鐨勬敮浠樺悗鍙扮敓鎴愮鍚嶄娇鐢ㄧ殑 timeStamp 瀛楁鍚嶉渶澶у啓鍏朵腑鐨� S 瀛楃 + nonceStr: response.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣� + package: response.packageValue, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_id鍙傛暟鍊硷紝鎻愪氦鏍煎紡濡傦細prepay_id=\*\*\*锛� + signType: response.signType, // 寰俊鏀粯V3鐨勪紶鍏� RSA ,寰俊鏀粯V2鐨勪紶鍏ユ牸寮忎笌V2缁熶竴涓嬪崟鐨勭鍚嶆牸寮忎繚鎸佷竴鑷� + paySign: response.paySign, // 鏀粯绛惧悕 + complete: (res) => { + console.log(res); + reject(res) + }, + success: function (res) { + // 鏀粯鎴愬姛鍚庣殑鍥炶皟鍑芥暟 + console.log(res); + resolve(res) + }, + // cancel: function (err) { + // reject(err) + // } + }) + }) + } +} + + + +export default new AuthWechat(); diff --git a/h5_standard/src/views/LogInAgain.vue b/h5_standard/src/views/LogInAgain.vue index 1828d7b..e28e4a7 100644 --- a/h5_standard/src/views/LogInAgain.vue +++ b/h5_standard/src/views/LogInAgain.vue @@ -117,7 +117,7 @@ window.localStorage.setItem('token', res.data) let info: any = await getUserInfo() if (info.code === 200) { - // await store.commit('setEntrance', 'H5') + await store.commit('setEntrance', 'H5') await store.commit('setUserInfo', info.data) await store.dispatch('getMenuList', 2) await router.go(-1) diff --git a/h5_standard/src/views/needToBeDealtWith/addWarehousing.vue b/h5_standard/src/views/needToBeDealtWith/addWarehousing.vue new file mode 100644 index 0000000..d8e4816 --- /dev/null +++ b/h5_standard/src/views/needToBeDealtWith/addWarehousing.vue @@ -0,0 +1,18 @@ +<template> + <div class="page"> + 鏂板鍏ュ簱 + </div> +</template> + +<script setup lang="ts"> + +</script> + +<style lang="scss" scoped> +.page { + width: 100%; + height: 100%; + position: absolute; + background: #F7F7F7; +} +</style> \ No newline at end of file diff --git a/h5_standard/src/views/needToBeDealtWith/outbound.vue b/h5_standard/src/views/needToBeDealtWith/outbound.vue new file mode 100644 index 0000000..5738353 --- /dev/null +++ b/h5_standard/src/views/needToBeDealtWith/outbound.vue @@ -0,0 +1,18 @@ +<template> + <div class="page"> + 鏂板鍑哄簱 + </div> +</template> + +<script setup lang="ts"> + +</script> + +<style lang="scss" scoped> +.page { + width: 100%; + height: 100%; + position: absolute; + background: #F7F7F7; +} +</style> \ No newline at end of file diff --git a/h5_standard/src/views/productionInspection/manualInspection.vue b/h5_standard/src/views/productionInspection/manualInspection.vue index 75dd00e..6635963 100644 --- a/h5_standard/src/views/productionInspection/manualInspection.vue +++ b/h5_standard/src/views/productionInspection/manualInspection.vue @@ -3,8 +3,13 @@ <div class="inspection_list"> <div class="inspection_list_item"> <span>妫�楠岀被鍨�</span> - <div class="right"> + <!-- <div class="right"> <div class="right_item" :class="{ 'active': item.active }" v-for="(item, index) in status" :key="index" @click="changeItem(index, item.id)">{{item.name}}</div> + </div> --> + <div class="right"> + <div class="right_item active">宸$嚎</div> + <!-- <div class="right_item active" v-if="form.status == '1'">宸℃</div> + <div class="right_item active" v-if="form.status == '2'">瀹屽伐妫�</div> --> </div> </div> </div> @@ -277,6 +282,7 @@ onMounted(() => { checkAllLists() + // /productionInspection/manualInspection // getListByConditions1() // toolingQueryByIds() }) diff --git a/h5_standard/src/views/productionInspection/manualInspection1.vue b/h5_standard/src/views/productionInspection/manualInspection1.vue new file mode 100644 index 0000000..b3ee363 --- /dev/null +++ b/h5_standard/src/views/productionInspection/manualInspection1.vue @@ -0,0 +1,402 @@ +<template> + <div class="inspection"> + <div class="inspection_list"> + <div class="inspection_list_item"> + <span>妫�楠岀被鍨�</span> + <!-- <div class="right"> + <div class="right_item" :class="{ 'active': item.active }" v-for="(item, index) in status" :key="index" @click="changeItem(index, item.id)">{{item.name}}</div> + </div> --> + <div class="right"> + <!-- <div class="right_item active">宸$嚎</div> --> + <div class="right_item active">宸℃</div> + <!-- <div class="right_item active" v-if="form.status == '2'">瀹屽伐妫�</div> --> + </div> + </div> + </div> + <div class="x"></div> + <div class="inspection_list"> + <div class="inspection_list_item" @click="jumpGD"> + <span>妫�楠屽伐鍗�</span> + <div class="right1"> + <span :style="form.gdmc ? 'color: #000;' : ''">{{ form.gdmc ? form.gdmc : '鐐瑰嚮閫夋嫨妫�楠屽伐鍗�'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> + <div class="inspection_list_item" v-if="form.gdmc"> + <span>璁″垝鏁伴噺</span> + <div class="right1"> + <span style="color: black;">{{data.info.planNum}}{{data.info.umodel ? data.info.umodel.name : ''}}</span> + </div> + </div> + <!-- <div class="inspection_list_item" @click="openGZ"> + <span>妫�楠屽伐瑁�</span> + <div class="right1"> + <span :style="form.jygzmc ? 'color: #000' : ''">{{ form.jygzmc ? form.jygzmc : '鐐瑰嚮閫夋嫨妫�楠屽伐瑁�'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> --> + </div> + <div class="x"></div> + <div class="inspection_list"> + <div class="inspection_list_item"> + <span>鑹搧鏁�</span> + <div class="right1"> + <input type="number" v-model="form.hgsl" placeholder="0" /> + <span class="dw" v-if="data.info.umodel">{{data.info.umodel.name}}</span> + </div> + </div> + <div class="inspection_list_item"> + <span>涓嶈壇鏁伴噺</span> + <div class="right1"> + <input type="number" v-model="form.blsl" placeholder="0" /> + <span class="dw" v-if="data.info.umodel">{{data.info.umodel.name}}</span> + </div> + </div> + <!-- <div class="inspection_list_item" @click="openBLGZ" v-show="form.blsl > 0"> + <span>涓嶈壇宸ヨ</span> + <div class="right1"> + <span :style="form.blgzmc ? 'color: #000;' : ''">{{ form.blgzmc ? form.blgzmc : '鐐瑰嚮閫夋嫨宸ヨ'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> --> + <div class="inspection_list_item" @click="openBL" v-show="form.blsl > 0"> + <span>涓嶈壇璇存槑</span> + <div class="right1"> + <span :style="form.blsm ? 'color: #000;' : ''">{{ form.blsm ? form.blsm : '鐐瑰嚮閫夋嫨涓嶈壇鍘熷洜'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> + </div> + <div class="inspection_footer"> + <button class="inspection_footer_sub" @click="submit" v-preventReClick>鎻愪氦</button> + </div> + <!-- 涓嶈壇璇存槑 --> + <van-popup v-model:show="data.show1" position="bottom" round :style="{ height: '50%' }"> + <van-picker + title="璇烽�夋嫨涓嶈壇璇存槑" + :columns="data.columns1" + @confirm="onConfirm1" + @cancel="onCancel1" + /> + </van-popup> + <!-- 宸ヨ --> + <Tooling :show="gzShow1" :classification="true" :statusname="'1,2,3'" :attribute="Attribute.HG" @close="close1" @value="getValue1" /> + <!-- 涓嶈壇宸ヨ --> + <Tooling :show="gzShow" :attribute="Attribute.BF + ',' + Attribute.BL" @close="close" @value="getValue" /> + </div> +</template> + +<script setup lang="ts"> + import { ref, reactive, onMounted, onActivated } from 'vue' + import { useRouter } from "vue-router" + import { Toast } from 'vant' + import { REGULAR } from '@/utils/utils' + import { Attribute } from '@/enum' + import { createStandard } from '@/apis/QualityAPI' + import { checkAllList, getListByCondition, toolingQueryById } from "@/apis/WorkOrderAPI" + import Tooling from '@/components/common/Tooling.vue' + + const router = useRouter() + + let gzShow = ref<boolean>(false) + + let gzShow1 = ref<boolean>(false) + + let data = reactive<any>({ + info: {}, + show1: false, + columns: [], + columns1: [] + }) + + let form = reactive({ + status: '1', + gdid: '', + gdmc: '', + jygz: '', + jygzmc: '', + hgsl: 0, + blsl: 0, + blgz: '', + blgzmc: '', + blsm: '', + dw: '' + }) + + let status = ref<Array<object>>([ + { id: '0', name: '宸$嚎', active: true }, + { id: '1', name: '宸℃', active: false }, + { id: '2', name: '瀹屽伐妫�', active: false } + ]) + + // 鍏抽棴涓嶈壇宸ヨ + const close = () => { + gzShow.value = false + } + + // 鍏抽棴宸ヨ + const close1 = () => { + gzShow1.value = false + } + + // 鑾峰彇涓嶈壇宸ヨ鏁版嵁 + const getValue = (item: any) => { + form.blgzmc = item.code + form.blgz = item.id + gzShow.value = false + } + + // 鑾峰彇宸ヨ鏁版嵁 + const getValue1 = (item: any) => { + form.dw = item.umodelData + form.jygz = item.id + form.jygzmc = item.code + gzShow1.value = false + } + + // 鎵撳紑妫�楠屽伐瑁� + const openGZ = () => { + gzShow1.value = true + } + + // 鍘婚�夋嫨璁惧 + const jumpGD = () => { + router.push({ name: 'selectWorkOrder' }) + } + + const openBL = () => { + data.show1 = true + } + + const openBLGZ = () => { + gzShow.value = true + } + + const onConfirm1 = (value: any): void => { + form.blsm = value.text + data.show1 = false + } + + const onCancel1 = () => { + data.show1 = false + } + + // 鍒囨崲鐘舵�� + const changeItem = (i: number, id: string): void => { + status.value.forEach((item: any, index: number) => { + item.active = i === index; + }) + form.status = id + } + + // 鎻愪氦 + const submit = () => { + if (!form.gdid) return Toast.fail({ message: '宸ュ崟涓嶈兘涓虹┖' }) + // if (!form.jygz) return Toast.fail({ message: '妫�楠屽伐瑁呬笉鑳戒负绌�' }) + if (form.hgsl || form.blsl) { + if (form.hgsl) { + if (form.dw == '0') { // 鏁存暟 + if (!REGULAR.positiveInteger.test(form.hgsl as never)) return Toast.fail({ message: '鑹搧鏁伴噺鍙兘涓烘鏁存暟' }) + } else if (form.dw == '1') { // 灏忔暟 + if (!REGULAR.number.test(form.hgsl as never)) { + return Toast.fail({ message: '鑹搧鏁伴噺鍙兘涓烘鏁存暟鎴栧洓浣嶅皬鏁�' }) + } + } + } + if (form.blsl) { + if (form.dw == '0') { // 鏁存暟 + if (!REGULAR.positiveInteger.test(form.blsl as never)) return Toast.fail({ message: '涓嶈壇鏁伴噺鍙兘涓烘鏁存暟' }) + } else if (form.dw == '1') { // 灏忔暟 + if (!REGULAR.number.test(form.blsl as never)) { + return Toast.fail({ message: '涓嶈壇鏁伴噺鍙兘涓烘鏁存暟鎴栧洓浣嶅皬鏁�' }) + } + } + } + } else { + return Toast.fail({ message: '鑹搧鍜屼笉鑹笉鑳藉悓鏃朵负绌�' }) + } + let total = (form.hgsl ? form.hgsl : 0) + (form.blsl ? form.blsl : 0) + if (total > data.info.planNum) { + return Toast.fail({ message: '鍚堟牸涓嶈壇鐩稿姞涓嶈兘瓒呰繃璁″垝鏁伴噺' }) + } + if (Number(form.blsl) > 0) { + // if (!form.blgz) return Toast.fail({ message: '涓嶈壇宸ヨ涓嶈兘涓虹┖' }) + if (!form.blsm) return Toast.fail({ message: '涓嶈壇璇存槑涓嶈兘涓虹┖' }) + } + createStandard({ + workorderId: form.gdid, + // appliancesId: form.jygz, + qualifiedNum: form.hgsl ? form.hgsl : 0, + unqualifiedNum: form.blsl ? form.blsl : 0, + // qualifiedApplianceId: form.blgz, + checkInfo: form.blsm, + checkType: form.status + }).then(res => { + if (res.code === 200) { + Toast.success({ message: '妫�楠屾垚鍔燂紒', duration: 2000, forbidClick: true }) + setTimeout(() => { + router.go(-1) + }, 2000) + } + }) + } + + // 涓嶈壇鍘熷洜鏁版嵁 + const checkAllLists = () => { + checkAllList({ bmodelCateType: '3' }) + .then(res => { + if (res.code === 200) { + res.data.forEach((item: any) => { + data.columns1.push({ text: item.combinationName, id: item.id }) + }) + } + }) + } + + // 鏌ヨ涓嶈壇/鎶ュ簾宸ヨ + const getListByConditions1 = () => { + data.columns2 = [] + getListByCondition({ + smodelLabel: 'APPLIANCE_OFFTEST,APPLIANCE_USELESS' + }).then(res => { + if (res.code === 200) { + res.data.forEach((item: any) => { + data.columns2.push({ text: '[' + item.smodelCode + '] ' + item.code, id: item.id }) + }) + } + }) + } + + // 鑾峰彇鎵�鏈夊伐瑁� + const toolingQueryByIds = () => { + data.columns3 = [] + toolingQueryById({}) + .then(res => { + if (res.code === 200) { + res.data.forEach((item: any) => { + data.columns3.push({ text: item.code, id: item.id }) + }) + } + }) + } + + onMounted(() => { + checkAllLists() + // /productionInspection/manualInspection + // getListByConditions1() + // toolingQueryByIds() + }) + + onActivated(() => { + let res: any = localStorage.getItem('workOder') + if (res) { + form.gdmc = JSON.parse(res).mmodel.name + '-' + JSON.parse(res).pgmodel.name + form.gdid = JSON.parse(res).id + data.info = JSON.parse(res) + localStorage.removeItem('workOder') + } + }) +</script> + +<style lang="scss" scoped> +.inspection { + width: 100%; + height: 100%; + position: absolute; + background: #F7F7F7; + .x { + height: 20px; + } + .inspection_list { + padding: 0 30px; + background: white; + .inspection_list_item { + height: 98px; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1PX solid #E5E5E5; + &:last-child { + border: none; + } + span { + font-size: 30px; + font-weight: 400; + color: #222222; + } + .right1 { + display: flex; + align-items: center; + span { + font-size: 28px; + font-weight: 400; + color: #999999; + margin-right: 10px; + } + input { + width: 180px; + height: 60px; + border-radius: 8px; + border: 1PX solid #CCCCCC; + margin-right: 10px; + padding: 0 30px; + box-sizing: border-box; + font-size: 28px; + } + input::-webkit-input-placeholder { + font-size: 28px; + font-weight: 400; + color: #999999; + } + .dw { + font-size: 28px; + font-weight: 400; + color: #666666; + } + } + .right { + display: flex; + align-items: center; + .active { + background: $nav-color !important; + color: #ffffff !important; + } + .right_item { + padding: 18px 32px; + background: #F2F2F2; + border-radius: 8px; + font-size: 26px; + font-weight: 400; + color: #333333; + display: flex; + align-items: center; + justify-content: center; + margin-left: 20px; + } + } + } + } + .inspection_footer { + position: fixed; + bottom: 0; + left: 0; + width: calc(100% - 60px); + padding: 30px 30px 68px 30px; + background: #F7F7F7; + .inspection_footer_sub { + width: 100%; + height: 88px; + background: #4275FC; + box-shadow: 0 0 12px 0 rgba(0,0,0,0.0800); + border-radius: 8px; + font-size: 30px; + font-weight: 500; + color: #FFFFFF; + display: flex; + align-items: center; + justify-content: center; + border: none; + } + } +} +</style> diff --git a/h5_standard/src/views/productionInspection/manualInspection2.vue b/h5_standard/src/views/productionInspection/manualInspection2.vue new file mode 100644 index 0000000..2fa4f6b --- /dev/null +++ b/h5_standard/src/views/productionInspection/manualInspection2.vue @@ -0,0 +1,402 @@ +<template> + <div class="inspection"> + <div class="inspection_list"> + <div class="inspection_list_item"> + <span>妫�楠岀被鍨�</span> + <!-- <div class="right"> + <div class="right_item" :class="{ 'active': item.active }" v-for="(item, index) in status" :key="index" @click="changeItem(index, item.id)">{{item.name}}</div> + </div> --> + <div class="right"> + <!-- <div class="right_item active">宸$嚎</div> --> + <!-- <div class="right_item active">宸℃</div> --> + <div class="right_item active">瀹屽伐妫�</div> + </div> + </div> + </div> + <div class="x"></div> + <div class="inspection_list"> + <div class="inspection_list_item" @click="jumpGD"> + <span>妫�楠屽伐鍗�</span> + <div class="right1"> + <span :style="form.gdmc ? 'color: #000;' : ''">{{ form.gdmc ? form.gdmc : '鐐瑰嚮閫夋嫨妫�楠屽伐鍗�'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> + <div class="inspection_list_item" v-if="form.gdmc"> + <span>璁″垝鏁伴噺</span> + <div class="right1"> + <span style="color: black;">{{data.info.planNum}}{{data.info.umodel ? data.info.umodel.name : ''}}</span> + </div> + </div> + <!-- <div class="inspection_list_item" @click="openGZ"> + <span>妫�楠屽伐瑁�</span> + <div class="right1"> + <span :style="form.jygzmc ? 'color: #000' : ''">{{ form.jygzmc ? form.jygzmc : '鐐瑰嚮閫夋嫨妫�楠屽伐瑁�'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> --> + </div> + <div class="x"></div> + <div class="inspection_list"> + <div class="inspection_list_item"> + <span>鑹搧鏁�</span> + <div class="right1"> + <input type="number" v-model="form.hgsl" placeholder="0" /> + <span class="dw" v-if="data.info.umodel">{{data.info.umodel.name}}</span> + </div> + </div> + <div class="inspection_list_item"> + <span>涓嶈壇鏁伴噺</span> + <div class="right1"> + <input type="number" v-model="form.blsl" placeholder="0" /> + <span class="dw" v-if="data.info.umodel">{{data.info.umodel.name}}</span> + </div> + </div> + <!-- <div class="inspection_list_item" @click="openBLGZ" v-show="form.blsl > 0"> + <span>涓嶈壇宸ヨ</span> + <div class="right1"> + <span :style="form.blgzmc ? 'color: #000;' : ''">{{ form.blgzmc ? form.blgzmc : '鐐瑰嚮閫夋嫨宸ヨ'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> --> + <div class="inspection_list_item" @click="openBL" v-show="form.blsl > 0"> + <span>涓嶈壇璇存槑</span> + <div class="right1"> + <span :style="form.blsm ? 'color: #000;' : ''">{{ form.blsm ? form.blsm : '鐐瑰嚮閫夋嫨涓嶈壇鍘熷洜'}}</span> + <van-icon name="arrow" color="#999999" size="18" /> + </div> + </div> + </div> + <div class="inspection_footer"> + <button class="inspection_footer_sub" @click="submit" v-preventReClick>鎻愪氦</button> + </div> + <!-- 涓嶈壇璇存槑 --> + <van-popup v-model:show="data.show1" position="bottom" round :style="{ height: '50%' }"> + <van-picker + title="璇烽�夋嫨涓嶈壇璇存槑" + :columns="data.columns1" + @confirm="onConfirm1" + @cancel="onCancel1" + /> + </van-popup> + <!-- 宸ヨ --> + <Tooling :show="gzShow1" :classification="true" :statusname="'1,2,3'" :attribute="Attribute.HG" @close="close1" @value="getValue1" /> + <!-- 涓嶈壇宸ヨ --> + <Tooling :show="gzShow" :attribute="Attribute.BF + ',' + Attribute.BL" @close="close" @value="getValue" /> + </div> +</template> + +<script setup lang="ts"> + import { ref, reactive, onMounted, onActivated } from 'vue' + import { useRouter } from "vue-router" + import { Toast } from 'vant' + import { REGULAR } from '@/utils/utils' + import { Attribute } from '@/enum' + import { createStandard } from '@/apis/QualityAPI' + import { checkAllList, getListByCondition, toolingQueryById } from "@/apis/WorkOrderAPI" + import Tooling from '@/components/common/Tooling.vue' + + const router = useRouter() + + let gzShow = ref<boolean>(false) + + let gzShow1 = ref<boolean>(false) + + let data = reactive<any>({ + info: {}, + show1: false, + columns: [], + columns1: [] + }) + + let form = reactive({ + status: '2', + gdid: '', + gdmc: '', + jygz: '', + jygzmc: '', + hgsl: 0, + blsl: 0, + blgz: '', + blgzmc: '', + blsm: '', + dw: '' + }) + + let status = ref<Array<object>>([ + { id: '0', name: '宸$嚎', active: true }, + { id: '1', name: '宸℃', active: false }, + { id: '2', name: '瀹屽伐妫�', active: false } + ]) + + // 鍏抽棴涓嶈壇宸ヨ + const close = () => { + gzShow.value = false + } + + // 鍏抽棴宸ヨ + const close1 = () => { + gzShow1.value = false + } + + // 鑾峰彇涓嶈壇宸ヨ鏁版嵁 + const getValue = (item: any) => { + form.blgzmc = item.code + form.blgz = item.id + gzShow.value = false + } + + // 鑾峰彇宸ヨ鏁版嵁 + const getValue1 = (item: any) => { + form.dw = item.umodelData + form.jygz = item.id + form.jygzmc = item.code + gzShow1.value = false + } + + // 鎵撳紑妫�楠屽伐瑁� + const openGZ = () => { + gzShow1.value = true + } + + // 鍘婚�夋嫨璁惧 + const jumpGD = () => { + router.push({ name: 'selectWorkOrder' }) + } + + const openBL = () => { + data.show1 = true + } + + const openBLGZ = () => { + gzShow.value = true + } + + const onConfirm1 = (value: any): void => { + form.blsm = value.text + data.show1 = false + } + + const onCancel1 = () => { + data.show1 = false + } + + // 鍒囨崲鐘舵�� + const changeItem = (i: number, id: string): void => { + status.value.forEach((item: any, index: number) => { + item.active = i === index; + }) + form.status = id + } + + // 鎻愪氦 + const submit = () => { + if (!form.gdid) return Toast.fail({ message: '宸ュ崟涓嶈兘涓虹┖' }) + // if (!form.jygz) return Toast.fail({ message: '妫�楠屽伐瑁呬笉鑳戒负绌�' }) + if (form.hgsl || form.blsl) { + if (form.hgsl) { + if (form.dw == '0') { // 鏁存暟 + if (!REGULAR.positiveInteger.test(form.hgsl as never)) return Toast.fail({ message: '鑹搧鏁伴噺鍙兘涓烘鏁存暟' }) + } else if (form.dw == '1') { // 灏忔暟 + if (!REGULAR.number.test(form.hgsl as never)) { + return Toast.fail({ message: '鑹搧鏁伴噺鍙兘涓烘鏁存暟鎴栧洓浣嶅皬鏁�' }) + } + } + } + if (form.blsl) { + if (form.dw == '0') { // 鏁存暟 + if (!REGULAR.positiveInteger.test(form.blsl as never)) return Toast.fail({ message: '涓嶈壇鏁伴噺鍙兘涓烘鏁存暟' }) + } else if (form.dw == '1') { // 灏忔暟 + if (!REGULAR.number.test(form.blsl as never)) { + return Toast.fail({ message: '涓嶈壇鏁伴噺鍙兘涓烘鏁存暟鎴栧洓浣嶅皬鏁�' }) + } + } + } + } else { + return Toast.fail({ message: '鑹搧鍜屼笉鑹笉鑳藉悓鏃朵负绌�' }) + } + let total = (form.hgsl ? form.hgsl : 0) + (form.blsl ? form.blsl : 0) + if (total > data.info.planNum) { + return Toast.fail({ message: '鍚堟牸涓嶈壇鐩稿姞涓嶈兘瓒呰繃璁″垝鏁伴噺' }) + } + if (Number(form.blsl) > 0) { + // if (!form.blgz) return Toast.fail({ message: '涓嶈壇宸ヨ涓嶈兘涓虹┖' }) + if (!form.blsm) return Toast.fail({ message: '涓嶈壇璇存槑涓嶈兘涓虹┖' }) + } + createStandard({ + workorderId: form.gdid, + // appliancesId: form.jygz, + qualifiedNum: form.hgsl ? form.hgsl : 0, + unqualifiedNum: form.blsl ? form.blsl : 0, + // qualifiedApplianceId: form.blgz, + checkInfo: form.blsm, + checkType: form.status + }).then(res => { + if (res.code === 200) { + Toast.success({ message: '妫�楠屾垚鍔燂紒', duration: 2000, forbidClick: true }) + setTimeout(() => { + router.go(-1) + }, 2000) + } + }) + } + + // 涓嶈壇鍘熷洜鏁版嵁 + const checkAllLists = () => { + checkAllList({ bmodelCateType: '3' }) + .then(res => { + if (res.code === 200) { + res.data.forEach((item: any) => { + data.columns1.push({ text: item.combinationName, id: item.id }) + }) + } + }) + } + + // 鏌ヨ涓嶈壇/鎶ュ簾宸ヨ + const getListByConditions1 = () => { + data.columns2 = [] + getListByCondition({ + smodelLabel: 'APPLIANCE_OFFTEST,APPLIANCE_USELESS' + }).then(res => { + if (res.code === 200) { + res.data.forEach((item: any) => { + data.columns2.push({ text: '[' + item.smodelCode + '] ' + item.code, id: item.id }) + }) + } + }) + } + + // 鑾峰彇鎵�鏈夊伐瑁� + const toolingQueryByIds = () => { + data.columns3 = [] + toolingQueryById({}) + .then(res => { + if (res.code === 200) { + res.data.forEach((item: any) => { + data.columns3.push({ text: item.code, id: item.id }) + }) + } + }) + } + + onMounted(() => { + checkAllLists() + // /productionInspection/manualInspection + // getListByConditions1() + // toolingQueryByIds() + }) + + onActivated(() => { + let res: any = localStorage.getItem('workOder') + if (res) { + form.gdmc = JSON.parse(res).mmodel.name + '-' + JSON.parse(res).pgmodel.name + form.gdid = JSON.parse(res).id + data.info = JSON.parse(res) + localStorage.removeItem('workOder') + } + }) +</script> + +<style lang="scss" scoped> +.inspection { + width: 100%; + height: 100%; + position: absolute; + background: #F7F7F7; + .x { + height: 20px; + } + .inspection_list { + padding: 0 30px; + background: white; + .inspection_list_item { + height: 98px; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1PX solid #E5E5E5; + &:last-child { + border: none; + } + span { + font-size: 30px; + font-weight: 400; + color: #222222; + } + .right1 { + display: flex; + align-items: center; + span { + font-size: 28px; + font-weight: 400; + color: #999999; + margin-right: 10px; + } + input { + width: 180px; + height: 60px; + border-radius: 8px; + border: 1PX solid #CCCCCC; + margin-right: 10px; + padding: 0 30px; + box-sizing: border-box; + font-size: 28px; + } + input::-webkit-input-placeholder { + font-size: 28px; + font-weight: 400; + color: #999999; + } + .dw { + font-size: 28px; + font-weight: 400; + color: #666666; + } + } + .right { + display: flex; + align-items: center; + .active { + background: $nav-color !important; + color: #ffffff !important; + } + .right_item { + padding: 18px 32px; + background: #F2F2F2; + border-radius: 8px; + font-size: 26px; + font-weight: 400; + color: #333333; + display: flex; + align-items: center; + justify-content: center; + margin-left: 20px; + } + } + } + } + .inspection_footer { + position: fixed; + bottom: 0; + left: 0; + width: calc(100% - 60px); + padding: 30px 30px 68px 30px; + background: #F7F7F7; + .inspection_footer_sub { + width: 100%; + height: 88px; + background: #4275FC; + box-shadow: 0 0 12px 0 rgba(0,0,0,0.0800); + border-radius: 8px; + font-size: 30px; + font-weight: 500; + color: #FFFFFF; + display: flex; + align-items: center; + justify-content: center; + border: none; + } + } +} +</style> diff --git a/h5_standard/src/views/wxLogin.vue b/h5_standard/src/views/wxLogin.vue index 44af9fb..87c9825 100644 --- a/h5_standard/src/views/wxLogin.vue +++ b/h5_standard/src/views/wxLogin.vue @@ -7,26 +7,86 @@ <div class="wx_login_list"> <div class="wx_login_list_item"> <img src="@/assets/icon/login_ic_code@2x.png" alt="" /> - <input type="text" placeholder="浼佷笟浠g爜" /> + <input type="text" v-model="from.companyId" placeholder="浼佷笟浠g爜" /> </div> <div class="wx_login_list_item"> <img src="@/assets/icon/login_ic_phone@2x.png" alt="" /> - <input type="text" placeholder="鎵嬫満鍙�" /> + <input type="text" maxlength="11" v-model="from.username" placeholder="鎵嬫満鍙�" /> </div> <div class="wx_login_list_item"> <img src="@/assets/icon/login_ic_password@2x.png" alt="" /> - <input type="text" placeholder="瀵嗙爜" /> + <input type="password" v-model="from.password" placeholder="瀵嗙爜" /> </div> </div> <div class="wx_login_footer"> - <div class="wx_login_footer_btn">绔嬪嵆鐧诲綍</div> + <div class="wx_login_footer_btn" @click="login">绔嬪嵆鐧诲綍</div> </div> </div> </div> </template> <script setup lang="ts"> +import { onMounted, reactive } from 'vue'; +import { useRoute, useRouter } from 'vue-router'; +import { useStore } from 'vuex'; +import { wxLogin, wxAccountLogin, getUserInfo } from '@/apis/index'; +import { Toast } from 'vant'; +const route = useRoute() +const router = useRouter() +const store = useStore() + +let from: any = reactive({ + openid: '', + unionid: '', + companyId: '', + username: '', + password: '' +}) + +const login = async () => { + if (!from.openid) return Toast('openid涓嶈兘涓虹┖') + if (!from.unionid) return Toast('unionid涓嶈兘涓虹┖') + if (!from.companyId) return Toast('浼佷笟浠g爜涓嶈兘涓虹┖') + if (!from.username) return Toast('鎵嬫満鍙蜂笉鑳戒负绌�') + if (!from.password) return Toast('瀵嗙爜涓嶈兘涓虹┖') + Toast.loading({ + message: '鐧诲綍涓�...', + forbidClick: true + }); + let res = await wxAccountLogin(from) + if (res.code === 200) { + let info = await getUserInfo() + if (info.code === 200) { + await store.commit('setEntrance', 'DD') + await store.commit('setUserInfo', info.data) + await store.dispatch('getMenuList', 2) + await router.replace('/workbench') + } + } + Toast.clear(); +} + +onMounted(() => { + wxLogin({ code: route.query.code }) + .then(async (res) => { + if (res.code === 200) { + // 鍏嶇櫥褰曪紝鐩存帴璺抽椤� + if (res.data.loginStatus == 0) { + let info = await getUserInfo() + if (info.code === 200) { + await store.commit('setEntrance', 'DD') + await store.commit('setUserInfo', info.data) + await store.dispatch('getMenuList', 2) + await router.replace('/workbench') + } + } else { + from.openid = res.data.openid + from.unionid = res.data.unionid + } + } + }) +}) </script> <style lang="scss" scoped> -- Gitblit v1.9.3