From fe95f471666d93e7822a4886c1c69dafbd6b2a1e Mon Sep 17 00:00:00 2001 From: wlzboy <66905212@qq.com> Date: 星期一, 22 九月 2025 17:57:31 +0800 Subject: [PATCH] feat:更新保存 --- ruoyi-ui/src/views/evaluation/index.vue | 188 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 186 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/views/evaluation/index.vue b/ruoyi-ui/src/views/evaluation/index.vue index 017d5af..d4db6f1 100644 --- a/ruoyi-ui/src/views/evaluation/index.vue +++ b/ruoyi-ui/src/views/evaluation/index.vue @@ -20,11 +20,41 @@ <!-- 瀹㈡埛淇℃伅 --> <div class="form-section"> <h3>瀹㈡埛淇℃伅</h3> + + <!-- 寰俊鎺堟潈淇℃伅鏄剧ず --> + <div v-if="evaluationForm.wechatOpenid" class="wechat-info"> + <div class="wechat-user"> + <img v-if="evaluationForm.wechatAvatar" :src="evaluationForm.wechatAvatar" class="wechat-avatar" /> + <div class="wechat-details"> + <div class="wechat-nickname">{{ evaluationForm.wechatNickname }}</div> + <div class="wechat-openid">宸叉巿鏉冨井淇$櫥褰�</div> + </div> + </div> + </div> + + <!-- 寰俊鎺堟潈鎸夐挳 --> + <div v-if="isWechatBrowser() && !evaluationForm.wechatOpenid" class="wechat-auth-section"> + <el-button + type="primary" + size="small" + @click="redirectToWechatAuth" + icon="el-icon-user" + :loading="wechatAuthLoading" + > + {{ wechatAuthLoading ? '姝e湪璺宠浆...' : '寰俊涓�閿櫥褰�' }} + </el-button> + <div class="wechat-tip">鐐瑰嚮鍙嚜鍔ㄨ幏鍙栨偍鐨勫井淇′俊鎭�</div> + </div> + <el-form-item label="濮撳悕" prop="customerName"> <el-input v-model="evaluationForm.customerName" placeholder="璇疯緭鍏ユ偍鐨勫鍚�" /> </el-form-item> <el-form-item label="鎵嬫満鍙�" prop="customerPhone"> <el-input v-model="evaluationForm.customerPhone" placeholder="璇疯緭鍏ユ偍鐨勬墜鏈哄彿" /> + <div v-if="evaluationForm.wechatOpenid" class="phone-tip"> + <i class="el-icon-info"></i> + 寰俊鎺堟潈鏃犳硶鐩存帴鑾峰彇鎵嬫満鍙凤紝璇锋墜鍔ㄨ緭鍏� + </div> </el-form-item> </div> @@ -118,7 +148,7 @@ </template> <script> -import { getEvaluationDimensions, submitEvaluation, getWechatUserInfo } from "@/api/evaluation"; +import { getEvaluationDimensions, submitEvaluation, getWechatUserInfo, getWechatAuthUrl } from "@/api/evaluation"; export default { name: "Evaluation", @@ -147,7 +177,8 @@ }, submitting: false, showResult: false, - resultMessage: '' + resultMessage: '', + wechatAuthLoading: false }; }, created() { @@ -178,7 +209,10 @@ // 澶勭悊寰俊鎺堟潈 async handleWechatAuth() { const code = this.$route.query.code; + const state = this.$route.query.state; + if (code) { + // 鏈夋巿鏉冪爜锛岃幏鍙栫敤鎴蜂俊鎭� try { const response = await getWechatUserInfo(code); if (response.code === 200) { @@ -187,10 +221,59 @@ this.evaluationForm.wechatNickname = userInfo.nickname; this.evaluationForm.wechatAvatar = userInfo.headimgurl; this.evaluationForm.wechatPhone = userInfo.phone || ''; + + // 濡傛灉鑾峰彇鍒颁簡寰俊鏄电О锛岃嚜鍔ㄥ~鍏呭埌濮撳悕瀛楁 + if (userInfo.nickname && !this.evaluationForm.customerName) { + this.evaluationForm.customerName = userInfo.nickname; + } + + this.$message.success('寰俊鎺堟潈鎴愬姛锛屽凡鑷姩鑾峰彇鎮ㄧ殑淇℃伅'); + } else { + this.$message.error(response.msg || '鑾峰彇寰俊鐢ㄦ埛淇℃伅澶辫触'); } } catch (error) { console.error('鑾峰彇寰俊鐢ㄦ埛淇℃伅澶辫触:', error); + this.$message.error('鑾峰彇寰俊鐢ㄦ埛淇℃伅澶辫触锛岃閲嶈瘯'); } + } else { + // 娌℃湁鎺堟潈鐮侊紝妫�鏌ユ槸鍚﹂渶瑕佽烦杞埌寰俊鎺堟潈 + const hasWechatInfo = this.evaluationForm.wechatOpenid; + if (!hasWechatInfo) { + await this.redirectToWechatAuth(); + } + } + }, + + // 璺宠浆鍒板井淇℃巿鏉� + async redirectToWechatAuth() { + this.wechatAuthLoading = true; + try { + // 鏋勫缓褰撳墠椤甸潰鐨勫畬鏁碪RL浣滀负鍥炶皟鍦板潃 + const currentUrl = window.location.origin + window.location.pathname; + const params = new URLSearchParams(window.location.search); + params.delete('code'); // 绉婚櫎鍙兘瀛樺湪鐨刢ode鍙傛暟 + params.delete('state'); // 绉婚櫎鍙兘瀛樺湪鐨剆tate鍙傛暟 + const redirectUri = currentUrl + (params.toString() ? '?' + params.toString() : ''); + + console.log('鍑嗗鐢熸垚寰俊鎺堟潈URL锛屽洖璋冨湴鍧�:', redirectUri); + + const response = await getWechatAuthUrl(redirectUri, 'evaluation'); + if (response.code === 200) { + console.log('寰俊鎺堟潈URL鐢熸垚鎴愬姛:', response.data); + console.log('鍘熷鍥炶皟鍦板潃:', response.data.originalRedirectUri); + console.log('寰俊AppID:', response.data.appId); + + // 璺宠浆鍒板井淇℃巿鏉冮〉闈� + window.location.href = response.data.authUrl; + } else { + console.error('鐢熸垚寰俊鎺堟潈URL澶辫触:', response.msg); + this.$message.error('寰俊鎺堟潈鏈嶅姟鏆傛椂涓嶅彲鐢紝璇锋墜鍔ㄥ~鍐欎俊鎭�'); + } + } catch (error) { + console.error('璺宠浆寰俊鎺堟潈澶辫触:', error); + this.$message.error('寰俊鎺堟潈澶辫触锛岃鎵嬪姩濉啓淇℃伅'); + } finally { + this.wechatAuthLoading = false; } }, @@ -465,6 +548,72 @@ min-height: 60px !important; } +/* 寰俊鎺堟潈鐩稿叧鏍峰紡 */ +.wechat-info { + background: #f0f9ff; + border: 1px solid #b3d8ff; + border-radius: 6px; + padding: 12px; + margin-bottom: 16px; +} + +.wechat-user { + display: flex; + align-items: center; +} + +.wechat-avatar { + width: 40px; + height: 40px; + border-radius: 50%; + margin-right: 12px; + border: 2px solid #409EFF; +} + +.wechat-details { + flex: 1; +} + +.wechat-nickname { + font-weight: bold; + color: #333; + font-size: 14px; + margin-bottom: 4px; +} + +.wechat-openid { + color: #666; + font-size: 12px; +} + +.wechat-auth-section { + text-align: center; + padding: 16px; + background: #f8f9fa; + border-radius: 6px; + margin-bottom: 16px; + border: 1px dashed #ddd; +} + +.wechat-tip { + color: #666; + font-size: 12px; + margin-top: 8px; +} + +.phone-tip { + color: #909399; + font-size: 12px; + margin-top: 4px; + display: flex; + align-items: center; +} + +.phone-tip i { + margin-right: 4px; + color: #409EFF; +} + /* 浼樺寲琛ㄥ崟椤归棿璺� */ .el-form-item { margin-bottom: 12px; @@ -628,6 +777,41 @@ padding: 8px 24px; font-size: 13px; } + + /* 绉诲姩绔井淇℃巿鏉冩牱寮� */ + .wechat-info { + padding: 10px; + margin-bottom: 12px; + } + + .wechat-avatar { + width: 36px; + height: 36px; + margin-right: 10px; + } + + .wechat-nickname { + font-size: 13px; + } + + .wechat-openid { + font-size: 11px; + } + + .wechat-auth-section { + padding: 12px; + margin-bottom: 12px; + } + + .wechat-tip { + font-size: 11px; + margin-top: 6px; + } + + .phone-tip { + font-size: 11px; + margin-top: 3px; + } } /* 瓒呭皬灞忓箷閫傞厤 */ -- Gitblit v1.9.1