Преглед на файлове

[v5.0.240611.2] 新增aigpt權益判斷

1. 調整權益檢核功能
2. 新增顯示gpt權益時間
osbert преди 1 година
родител
ревизия
acc3e025ca

+ 25 - 0
HiTeachCC/ClientApp/src/api/bbApi.js

@@ -0,0 +1,25 @@
+import { post } from '@/filter/http'
+import { jsFn } from '@/utils/jsFn'
+import profile from '@/utils/profile'
+
+var serverLocation = jsFn.isCN() ? 'cn' : 'global'
+let hostname = window.location.hostname
+if(hostname.indexOf('localhost') === 0) {
+    serverLocation = 'globalrc'
+}
+
+var apiUrl = profile.BBUrl[serverLocation]
+
+
+export default {
+    // 取得個人授權
+    getTMIDService: function() {
+        return new Promise((resolve, reject) => {
+            post(apiUrl + '/hiteach/get-tmid-service', {}).then((res) => {
+                resolve(res)
+            }, err => {
+                reject(err)
+            })
+        })
+    }
+}

+ 1 - 1
HiTeachCC/ClientApp/src/api/ies5Api.js

@@ -8,7 +8,7 @@ if(hostname.indexOf('localhost') === 0 || hostname.indexOf('-rc') > 0) {
 }
 var apiUrl = profile.ies5Api[serverLocation]
 export default {
-    // 取得快速登入CODE
+    // 取得教師資訊
     getUserBlob: function() {
         return new Promise((resolve, reject) => {
             post(apiUrl + '/hiteachcc/get-teacher-info').then(res => {

+ 3 - 1
HiTeachCC/ClientApp/src/api/index.js

@@ -1,6 +1,7 @@
 import { fetch, post } from '@/filter/http'
 import coreApi from './coreApi'
 import ies5Api from './ies5Api'
+import bbApi from './bbApi'
 export default {
 //   //TW获取token 可能用不到 先註解
 //   getLoginInfo: function (data) {
@@ -61,5 +62,6 @@ export default {
 //       return post('/common/login/blob-auth')
 //   },
   coreApi,
-  ies5Api
+  ies5Api,
+  bbApi
 }

+ 1 - 0
HiTeachCC/ClientApp/src/filter/http.js

@@ -61,6 +61,7 @@ axios.interceptors.request.use(
                 }
 
             }
+            config.headers['accept'] = 'application/json'
             config.headers['Authorization'] = sessionStorage.getItem('token_type') + ' ' + sessionStorage.getItem('access_token')
             config.headers['Content-Type'] = 'application/json'
             config.headers['X-Auth-IdToken'] = sessionStorage.getItem('idToken')

+ 1 - 0
HiTeachCC/ClientApp/src/locale/lang/en-US/index.js

@@ -64,6 +64,7 @@ export default {
     您的使用權限:'Permission',
     學生連線數:'Max participants',
     作品收集數:'Max collection tasks',
+    aigptEXP:'AIGPT EXP',
     權限到期:'Upgraded until',
     '無法使用,已達您的權限作品收集數上限':'Sorry, you have reached the maximum number of collection tasks with your permission',
     '偵測到有請求加入,但加入教室人數已達您的權限人數上限':'A request to join your lesson has been detected, but the number of people who joined has reached your permission limit.',

+ 1 - 0
HiTeachCC/ClientApp/src/locale/lang/zh-CN/index.js

@@ -64,6 +64,7 @@ export default {
     您的使用權限:'您的使用权限',
     學生連線數:'学生连接数',
     作品收集數:'作品收集数',
+    aigptEXP:'AIGPT 到期时间',
     權限到期:'权益到期时间',
     '無法使用,已達您的權限作品收集數上限':'对不起,作品任务数已达上限',
     '偵測到有請求加入,但加入教室人數已達您的權限人數上限':'对不起,学生连接数已达上限',

+ 1 - 0
HiTeachCC/ClientApp/src/locale/lang/zh-TW/index.js

@@ -64,6 +64,7 @@ export default {
     您的使用權限:'您的權限',
     學生連線數:'連線人數',
     作品收集數:'作品收集數',
+    aigptEXP:'AIGPT 到期時間',
     權限到期:'專屬權益期間',
     '無法使用,已達您的權限作品收集數上限':'很抱歉,作品任務數已達上限',
     '偵測到有請求加入,但加入教室人數已達您的權限人數上限':'很抱歉,教室連線人數已達上限',

+ 1 - 1
HiTeachCC/ClientApp/src/store/index.js

@@ -201,7 +201,7 @@ export default new Vuex.Store({
     startTime: 0,
     elapsedTime: 0,
     timeLineEvents: [],
-    version: 'v5.0.240105.1'
+    version: 'v5.0.240611.2'
   },
   mutations: {},
   actions: {

+ 43 - 53
HiTeachCC/ClientApp/src/store/module/funcs.js

@@ -7,33 +7,19 @@ export default {
     namespaced: true,
     state: {
         funcs: [ // 預計以後會開放的功能 以下以最大數量為主)
-            { func: 'works', para: '1', get: null, exp: null }, // 作品收集任務數 (掃碼改為 6)
-            { func: 'clients', para: '10', get: null, exp: null }, // 連線人數 (掃碼改為 50)
-            { func: 'pageqty', para: '50', get: null, exp: null } // 頁面數
+            { func: 'works', para: '1', get: null, exp: null, active: true, isDeadline: false}, // 作品收集任務數 (掃碼改為 6)
+            { func: 'clients', para: '10', get: null, exp: null, active: true, isDeadline: false }, // 連線人數 (掃碼改為 50)
+            { func: 'pageqty', para: '50', get: null, exp: null, active: true, isDeadline: false }, // 頁面數
+            { func: 'aigpt', para: null, get: null, exp: null, active: false, isDeadline: false }, // AIGPT
         ]
     },
     getters: {
         // 取得指定的功能設定
         getFunc: (state) => (func) => {
             let data = state.funcs.find(item => item.func === func)
-            let isDeadline = false
-            
-            if(data.exp !== null){
-                let nY = new Date().getFullYear()
-                let expYear
-                if(data.exp.toString().length < 13) {
-                    expYear = new Date(data.exp * 1000).getFullYear()
-                } else {
-                    expYear = new Date(data.exp).getFullYear()
-                }
-                if((expYear - nY) < 50) {
-                    isDeadline = true
-                }
-            }
-
-            data.isDeadline = isDeadline
             return data
-        }
+        },
+        getFuncAll: (state) => state.funcs
     },
     mutations: {
         [KEEPSTORAGE](state, data) {
@@ -43,8 +29,13 @@ export default {
             })
         },
         [SETUPFUNCS](state, data) {
-            state.funcs = data
-        }
+            data.forEach(d => {
+                var i = state.funcs.findIndex((e) => e.func == d.func)
+                if(i != -1){
+                    state.funcs[i] = d
+                }
+            })
+        },
     },
     actions: {
         /**
@@ -56,49 +47,48 @@ export default {
                 let funcData = []
                 let nT = parseInt(Date.parse(new Date())/1000) // 用十碼計算
 
-                context.state.funcs.forEach( sItem => {
-                    let stemp = sItem
+                data.forEach( (d) => {
                     let exp
-                    // 提取對應 data 內容
-                    let dataTmp = data.find( d => d.func === sItem.func)
+                    let stateTmp = context.state.funcs.find( e => e.func === d.func)
+                    let index = funcData.findIndex( (e) => e.func == d.func)
+                    let tmpExp = nT
+                    if(index != -1 && funcData[index].exp > nT) {
+                        tmpExp = funcData[index].exp
+                    }
 
-                    // 根據不同類型作比較 留下較大的值
-                    switch (dataTmp?.func) {
-                        case 'works':
-                            exp = dataTmp.exp
-                            // 如果超過10碼調整為10碼
-                            if(exp.toString().length > 10 ) exp = parseInt(exp/1000)
-                            
-                            if((exp - nT) > 0 && parseInt(stemp.para) < parseInt(dataTmp.para)) { // 檢查功能是否過期,沒過期比較大小值
-                                stemp.para = dataTmp.para
-                                stemp.exp = dataTmp.exp
-                                stemp.get = dataTmp.get
-                            }
-                            break;
-                        case 'clients':
-                            exp = dataTmp.exp
+                    if(stateTmp.exp != null && stateTmp.exp > tmpExp) {
+                        tmpExp = stateTmp.exp
+                    }
+
+                    switch (stateTmp?.func) {
+                        case 'aigpt':
+                            exp = d.exp
                             // 如果超過10碼調整為10碼
                             if(exp.toString().length > 10 ) exp = parseInt(exp/1000)
 
-                            if((exp - nT) > 0 && parseInt(stemp.para) < parseInt(dataTmp.para)) { // 檢查功能是否過期,沒過期比較大小值
-                                stemp.para = dataTmp.para
-                                stemp.exp = dataTmp.exp
-                                stemp.get = dataTmp.get
+                            if((exp - tmpExp) > 0) {
+                                stateTmp.para = d.para
+                                stateTmp.exp = d.exp
+                                stateTmp.get = d.get
+                                stateTmp.isDeadline = true
+                                stateTmp.active = true
                             }
+
                             break;
-                        case 'pageqty':
-                            exp = dataTmp.exp
+                        default:
+                            exp = d.exp
                             // 如果超過10碼調整為10碼
                             if(exp.toString().length > 10 ) exp = parseInt(exp/1000)
                             
-                            if((exp - nT) > 0 && parseInt(stemp.para) < parseInt(dataTmp.para)) { // 檢查功能是否過期,沒過期比較大小值
-                                stemp.para = dataTmp.para
-                                stemp.exp = dataTmp.exp
-                                stemp.get = dataTmp.get
+                            if((exp - tmpExp) > 0 && parseInt(stateTmp.para) < parseInt(d.para)) { // 檢查功能是否過期,沒過期比較大小值
+                                stateTmp.para = d.para
+                                stateTmp.exp = d.exp
+                                stateTmp.get = d.get
+                                stateTmp.isDeadline = true
                             }
-                            break;
                     }
-                    funcData.push(stemp)
+
+                    funcData.push(stateTmp)
                 })
                 context.commit(SETUPFUNCS, funcData)
                 context.dispatch('saveState') // 存到sessionStorage

+ 5 - 0
HiTeachCC/ClientApp/src/utils/profile.js

@@ -32,6 +32,11 @@ export default {
         global: 'https://irs5.teammodel.net',
         cn: 'https://irs5.teammodel.cn'
     },
+    BBUrl: {
+        global: 'https://bb.teammodel.net',
+        cn: 'https://bb.teammodel.cn',
+        globalrc: 'https://bb-rc.teammodel.net',
+    },
     communityUrl: function(provider, redirectUri) {
         let result
         switch (provider) {

+ 5 - 0
HiTeachCC/ClientApp/src/views/Board.vue

@@ -195,6 +195,7 @@
               {{ $t("board['您的使用權限']") }}:{{ $t("board['學生連線數']") }}:<span class="limit-num">{{ limitClient }}</span
               >, {{ $t("board['作品收集數']") }}:<span class="limit-num">{{ limitCollate }} </span>
               <p class="limit-num" v-show="limitTime != 0">&nbsp;&nbsp;({{ $t("board['權限到期']") + ":" + limitTime }})</p>
+              <p class="limit-num" v-show="aigptTime != 0">&nbsp;&nbsp;({{ $t("board['aigptEXP']") + ":" + aigptTime }})</p>
               <p v-if="!schoolName" class="limit-note">{{ $t("board['權益說明']") }}</p>
               <p v-if="schoolName" class="limit-note">{{ schoolName }}</p>
             </div>
@@ -760,6 +761,7 @@ export default {
       limitCollate: 0,
       limitClient: 0,
       limitTime: 0,
+      aigptTime: 0,
       //限制只提示一次
       limitClientHint: false,
       isShowAskPasteWhichPage: false, //詢問要貼本頁或新增到一頁空白頁貼回,
@@ -7445,10 +7447,13 @@ export default {
     this.activityRecordNumberS = this.classInfo.activityRecordNumber;
 
     // 權益
+    console.log(this.getFunc("aigpt"), "aigpt"); // AIGPT
     console.log(this.getFunc("works"), "works"); // 作品收集任務數
     console.log(this.getFunc("clients"), "clients"); // 連線人數
     this.limitTime = this.getFunc("clients").isDeadline == true ? moment(this.getFunc("clients").exp * 1000).format("YYYY.MM.DD") : 0;
+    this.aigptTime = this.getFunc("aigpt").isDeadline == true ? moment(this.getFunc("aigpt").exp * 1000).format("YYYY.MM.DD") : 0;
     console.log(this.limitTime, "exptime");
+    console.log(this.aigptTime, "aigptTime");
     this.limitCollate = this.getFunc("works").para;
     this.limitClient = this.getFunc("clients").para;
 

+ 34 - 2
HiTeachCC/ClientApp/src/views/Login.vue

@@ -85,6 +85,7 @@
     import qrcodeImg from '@/assets/img/login/hbk_tmd.svg'
     const de = require('@/utils/lib1.js')
     import enc from '@/utils/enc.js'
+    import { mapGetters } from "vuex";
 
     export default {
         components: {
@@ -156,6 +157,10 @@
             }
         },
         computed: {
+            ...mapGetters({
+                getFunc: "funcs/getFunc",
+                getFuncAll: "funcs/getFuncAll"
+            }),
             pwState: function(){
                 if(this.pwVisibility){
                     return {
@@ -287,11 +292,39 @@
                     //  { func: 'pageqty', para: 60, get: '1646120382', exp: '1646120382'} // 頁面數
                     // ]
 
+                    let tmp = []
+                    let hiCC = []
+                    let hiTh = []
+
                     if(!!res.hiteachcc){
-                        this.$store.dispatch('funcs/setup', res.hiteachcc)
+                        hiCC = res.hiteachcc
+                    }
+
+                    if(!!res.hiteach){
+                        // 配合活動只針對aigpt確認
+                        let i = res.hiteach.findIndex((e) => e.func == 'aigpt');
+                        if(i != -1){
+                            hiTh.push(res.hiteach[i])
+                        }
+                    }
+
+                    tmp = hiCC.concat(hiTh)
+
+                    if(tmp.length > 0){
+                        this.$store.dispatch('funcs/setup', tmp)
                     }
                 })
 
+                // 取得個人授權
+                await this.$api.bbApi.getTMIDService().then(res => {
+                    // 配合活動只針對aigpt確認
+                    const index = res.findIndex((e) => e.prodCode == 'Z6ELB6EZ');
+                    if(index != -1 && !!res[index]?.aprule['aigpt']){
+                        this.$store.dispatch('funcs/setup', [{ func: 'aigpt', para: null, get: res[index].startDate, exp: res[index].endDate }])
+                    }
+                })
+
+
                 // 取得個人偏好設定
                 await this.$api.coreApi.getSettings(sessionStorage.getItem('idToken')).then(res => {
                     if(!!res.data.pref){
@@ -577,7 +610,6 @@
             }
         },
         mounted() {
-           
             this.loginCallback()
             // if (this._isMobile()) {
             //     this.$router.push('/mobilelogin')