From 9a6cd220224fd3a9a6c84b5bb37c6410a470969f Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期二, 17 三月 2026 17:53:21 +0800
Subject: [PATCH] 考点核验

---
 src/utils/wxjssdk.js |  263 ++--------------------------------------------------
 1 files changed, 10 insertions(+), 253 deletions(-)

diff --git a/src/utils/wxjssdk.js b/src/utils/wxjssdk.js
index 083dcda..7312be2 100644
--- a/src/utils/wxjssdk.js
+++ b/src/utils/wxjssdk.js
@@ -1,16 +1,14 @@
 import wx from 'weixin-js-sdk'
 import axios from './axios'
-import store from '../store.js'
 import $qxueyou from '@/config/qxueyou.js'
-import utilsUA from '@/plugins/utilsUA'
-import { getUUID, qxyResImg } from '@/plugins/utils'
+import { isWeixin, isMobile } from '@/utils/UA.js'
 
 let newFeature = false
 let oldShare = ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareQZone']
 let newShare = ['updateTimelineShareData', 'updateAppMessageShareData']
 
-let weixinFlag = utilsUA.isWeixin
-let mobileFlag = utilsUA.isMobile
+let weixinFlag = isWeixin
+let mobileFlag = isMobile
 let channel = weixinFlag && mobileFlag ? 'wx_pub' : 'wx_pub_qr'
 let isWxpub = 'wx_pub'.includes(channel)
 
@@ -21,7 +19,7 @@
 function getWxSignature(toRoute) { 
   if (!weixinFlag) { return false }
 
-  axios.get('/wx/js/signature', {
+  axios.get('/system/wx/js/signature', {
     params: { url: location.href } 
   }).then(res => {
     if (!res || !res.data) {
@@ -36,193 +34,19 @@
       signature: result.signature,
       jsApiList: [
         ...(newFeature ? newShare : oldShare),
-        'chooseWXPay',
+        // 'chooseWXPay',
         'chooseImage',
         'getLocalImgData'
       ],
       openTagList: ['wx-open-launch-app']
     })
-    wx.ready(function () {
-      initShareOption(toRoute)
-    })
+    // wx.ready(function () {
+    //   initShareOption(toRoute)
+    // })
     wx.error(function (res) {
       console.log(res)
     })
   })
-}
-
-/**
- * 鍒濆鍖栧垎浜暟鎹�
- * @param {*} toRoute 
- */
-function initShareOption(toRoute) {
-  if (!weixinFlag) { return false }
-
-  let uuid = getUUID()
-  let shareOptions = getShareOptions(uuid,toRoute)
-
-  shareOptions.success = function () {
-    shareSuccess(uuid,toRoute)
-  }
-  shareOptions.cancel = function () {
-    console.log('鍙栨秷鍒嗕韩')
-  }
-  shareOptions.trigger = function () {
-    console.log('鐢ㄦ埛鐐瑰嚮鍙戦�佺粰鏈嬪弸')
-  }
-
-  // 鍚戜笅鍏煎鏃х増鍒嗕韩鎺ュ彛
-  if (!newFeature) {
-    wx.onMenuShareTimeline(shareOptions)
-    wx.onMenuShareAppMessage(shareOptions)
-  } else {
-    wx.updateAppMessageShareData(shareOptions)
-    wx.updateTimelineShareData(shareOptions)
-  }
-}
-
-/**
- * 鑾峰彇鍒嗕韩鏁版嵁
- * @param {*} list 
- */
-function getShareOptions(uuid,toRoute) {
-  let result = {}
-  let customShare = store.state.share.custom
-  if (customShare.title) {
-    result.title = customShare.title
-    result.desc = customShare.desc
-  } else {
-    result.title = toRoute.name
-    result.desc = toRoute.name
-  }
-  if (customShare.imgUrl) {
-    if (customShare.imgUrl.includes('http')) {
-      result.imgUrl = customShare.imgUrl
-    } else {
-      result.imgUrl = qxyResImg(customShare.imgUrl)
-    }
-  }
-
-  if (customShare.uuidLink) {
-    let pageUrl = customShare.pageUrl || toRoute.fullPath
-    let encode = encodeURI(`${uuid},${$qxueyou.htmlRoot + pageUrl}`)
-    result.link = customShare.uuidLink + btoa(encode)
-    // result.link = customShare.uuidLink + uuid
-  } else if (customShare.link) {
-    result.link = customShare.link
-  } else {
-    result.link = location.href
-  }
-
-  return result
-}
-
-/**
- * 鍒嗕韩鎴愬姛鍥炶皟
- */
-function shareSuccess(uuid,toRoute) {
-  let customShare = store.state.share.custom
-  if (customShare.targetId) {
-    let pageUrl = customShare.pageUrl || toRoute.fullPath
-    axios.post('/wx/share/callback', {
-      urlId: uuid,
-      pageUrl: $qxueyou.htmlRoot + pageUrl,
-      targetId: customShare.targetId,
-      planIds: customShare.planIds
-    }).then(() => {
-      initShareOption(toRoute)
-    })
-  }
-
-  // 褰撳垎浜湁鏂规Id锛岃Е鍙戞槸鍚﹀叧娉ㄥ叕浼楀彿
-  if (customShare.planIds) {
-    store.commit('wxh5/subscribe', '鍙婃椂鑾峰彇濂栧姳鎻愰啋')
-  }
-
-  let mask = store.state.share.mask
-  if (mask.show) {
-    let text = mask.type === 'plan' ? '鍒嗕韩鎴愬姛锛岀户缁姪鍔�' : '閭�璇锋垚鍔燂紝缁х画閭�璇�'
-    let newMask = { show: true, type: mask.type, text: text, codeText: mask.codeText }
-    store.commit("share/maskText", newMask)
-  }
-}
-
-/**
- * 缁熶竴鏀粯鎺ュ彛澶勭悊
- * @param {*} orderId
- * @param {*} successCallback // 鏀粯鎴愬姛鍥炶皟
- * @param {*} showCodeCallback // 鏄剧ず浜岀淮鐮佸洖璋�
- */
-function unipayPay(orderId, successCallback, showCodeCallback) {
-  axios.post('/wx/pay/createOrder', {
-    orderId: orderId,
-    channel: channel,
-    redirectUrl: weixinFlag ? store.state.order.paySuccessUrl : undefined,
-  }).then(res => {
-    if (!res.data.data) { return false }
-    
-    let params = res.data.data.param
-
-    if (isWxpub) { // 鍏紬鍙锋敮浠�
-      chooseWXPay(params, successCallback)
-    } else { // 鎵爜鏀粯
-      store.commit('timer/paying', true)
-      showCodeCallback && showCodeCallback(params.codeUrl)
-      checkIsPay(orderId, successCallback)
-    }
-  })
-}
-
-function chooseWXPay(result, successCallback) {
-  //璋冪敤寰俊鏀粯鎺ュ彛
-  wx.chooseWXPay({
-    timestamp: result.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴筹紝娉ㄦ剰寰俊jssdk涓殑鎵�鏈変娇鐢╰imestamp瀛楁鍧囦负灏忓啓銆備絾鏈�鏂扮増鐨勬敮浠樺悗鍙扮敓鎴愮鍚嶄娇鐢ㄧ殑timeStamp瀛楁鍚嶉渶澶у啓鍏朵腑鐨凷瀛楃
-    nonceStr: result.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣�
-    package: result.packageValue, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_id鍙傛暟鍊硷紝鎻愪氦鏍煎紡濡傦細prepay_id=\*\*\*锛�
-    signType: result.signType, // 绛惧悕鏂瑰紡锛岄粯璁や负'SHA1'锛屼娇鐢ㄦ柊鐗堟敮浠橀渶浼犲叆'MD5'
-    paySign: result.paySign, // 鏀粯绛惧悕
-    success: () => {
-      successCallback && successCallback()
-    },
-    fail: (e) => {
-      store.commit('snack/error', '璇疯仈绯绘妧鏈鏈嶈В鍐�' + e.errMsg)
-    }
-  })
-}
-
-/**
- * 鎵爜鏀粯鎴愬姛鐨勫洖璋�
- * @param {} orderId
- * @returns {} 
- */
-function checkIsPay(orderId, successCallback) {
-  if (!store.state.timer.paying) {
-    return false
-  }
-  setTimeout(function () {
-    axios.get('/transact/order/payResult', {
-      params: { orderId: orderId }
-    }).then(res => {
-      if (res.data.success) {
-        successCallback && successCallback()
-        store.commit('timer/paying', false)
-      } else {
-        checkIsPay(orderId, successCallback)
-      }
-    })
-  }, 2000)
-}
-
-/**
- * 鑾峰彇瀹氫綅
- * @param {*} locationCallback 
- */
-function getPosition(locationCallback){
-  wx.getLocation({
-    success: function (res) {
-      locationCallback(res)
-    }
-  })  
 }
 
 function chooseImage(){
@@ -246,6 +70,7 @@
     })
   })
 }
+
 function getLocalImgData(localId){
   return new Promise((resolve) => {
     wx.getLocalImgData({
@@ -260,75 +85,7 @@
   })
 }
 
-
-/**
- * 棰勮鍥剧墖
- * @param {*} url 
- * @param {*} urlList 
- */
-function previewImage(current, urls){
-  wx.previewImage({
-    current: current, // 褰撳墠鏄剧ず鍥剧墖鐨刪ttp閾炬帴
-    urls: urls ? urls : [current] // 闇�瑕侀瑙堢殑鍥剧墖http閾炬帴鍒楄〃
-  })
-}
-
-/**
- * 杩斿洖灏忕▼搴忛〉闈�
- * @param {*} mpRouter // 灏忕▼搴忕殑璺敱
- * @param {*} otherCallback // 鍏朵粬鍥炶皟鎿嶄綔
- */
-function redirectToMp(mpRouter) {
-  return new Promise(resolve => {
-    // 闈炲井淇� 鎴� 浜虹ぞ灞�娲诲姩鍏ュ彛
-    if (!weixinFlag || store.state.course.isRsjActivity) {
-      resolve(true)
-      return false
-    }
-    wx.miniProgram.getEnv(function(res) {
-      if (res.miniprogram) { // 灏忕▼搴�
-        wx.miniProgram.redirectTo({
-          url: mpRouter,
-          success: function(){
-            console.log('璺宠浆鎴愬姛')
-            setTimeout(() => { // 澶勭悊鍏朵粬鏈烘瀯鐨勫皬绋嬪簭璺宠浆鍦烘櫙
-              resolve(true);
-            }, 3000)
-          },
-          fail: function(){
-            resolve(true)
-          }
-        })
-      } else { // 闈炲皬绋嬪簭
-        resolve(true)
-      }
-    })
-  })
-}
-
-/**
- * 鍚戝皬绋嬪簭鍙戦�佹秷鎭�
- */
-function postMessage(data) {
-  // 闈炲井淇�
-  if (!weixinFlag) { return false }
-
-  wx.miniProgram.getEnv(function(res) {
-    if (res.miniprogram) { // 灏忕▼搴�
-      wx.miniProgram.postMessage({
-        data: data
-      })
-    }
-  })
-}
-
 export {
   getWxSignature,
-  initShareOption,
-  unipayPay,
-  getPosition,
-  previewImage,
-  chooseImage,
-  redirectToMp,
-  postMessage
+  chooseImage
 }

--
Gitblit v1.8.0