123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- export default {
- data() {
- return {
- imgUrl: `${this.$config.FILE_URL}/document/newFile/download/0/${this.$config.FILE_UPLOAD_KEY}?fileKey=`,
- // 远程图片
- remoteImgUrl: `${this.$config.STATIC_IMG_URL}/`,
- // 云机列表
- cloudList: [],
- // 套餐类型
- mealTypeList: [],
- mealTypeObj: {},
- // 分组栏
- groupList: []
- }
- },
- methods: {
- /**
- * 根据卡套餐获取对应图标
- * @method imgFun
- * @param {String} type--1 套餐类型 VIP|SVIP|STARRYSKY
- * @param {String} androidVersion--2 安卓系统版本
- * @param {String} key='previewUrl'--3 ['previewUrl' | 'phonePreviewUrl'] 判断是预览图还是套餐图标用的
- * @returns {String} 图片路径
- */
- imgFun(type, androidVersion = '', key = 'previewUrl') {
- let obj = this.mealTypeObj[type + androidVersion]
- // obj[key]的值是default或defaultPhonePreviewUrl时候,就是后端没有返回图标还有预览图过来,显示默认的
- return obj[key] === 'default' ? '/static/img/userMealUpgradeVO_icon.png' : (obj[key] === 'defaultPhonePreviewUrl' ?
- this.remoteImgUrl + 'defalut-preview.png' : obj[key])
- },
- // 获取用户云手机列表
- async getCloudList() {
- try {
- const result = await this.$axios.get('/resources/v6/client/device/info/getDeviceList');
- if(result.status === 200 && result.data.status === 0 && result.data.success) {
- this.cloudList = result.data.data.diskInfo ?? [];
- }
- } catch (error) {
- console.error('获取云手机列表失败', error)
- }
- },
- // 获取云手机套餐,显示套餐名称和图标
- async getMealIconInfo() {
- try {
- const result = await this.$axios.get('/pay/v2/meal/info/getMealIconInfo');
- if(result.status === 200 && result.data.status === 0 && result.data.success) {
- const res = result.data;
- let obj = {} // eg: {VIP7: xxx, VIP10: xxx, SVIP7: xxx,...}
- let casualObj = {} // eg: {VIP: xxx, SVIP: xxx}
- let mealTypeList = [] // eg: [{label:xxx, value: xxx, previewUrl: xxx, androidVersionList: [7,10]}, ...]
- let mealTypeObj = {} // 同obj对象
- let index = 0; // 数据位置
- for (let i of res.data) {
- if (!casualObj[i.phoneType]) {
- casualObj[i.phoneType] = {
- label: i.phoneTypeName,
- value: i.phoneType,
- previewUrl: 'default',
- phonePreviewUrl: 'defaultPhonePreviewUrl',
- androidVersionList: [],
- index
- }
- index++
- }
-
- let androidVersionObj = {
- label: `安卓${i.androidVersion}`,
- value: i.androidVersion,
- previewUrl: i.previewUrl
- }
-
- casualObj[i.phoneType].androidVersionList.push(androidVersionObj)
-
- // 排序
- casualObj[i.phoneType].androidVersionList.sort((a, b) => a.value - b.value)
-
- if (obj[i.phoneType + i.androidVersion]) continue
- obj[i.phoneType + i.androidVersion] = i
- }
- mealTypeList = Object.values(casualObj);
- mealTypeObj = obj;
- Object.assign(mealTypeObj, casualObj);
- this.mealTypeList = mealTypeList;
- this.mealTypeObj = mealTypeObj;
-
- console.log('套餐图标数据', mealTypeList, mealTypeObj)
- }
- } catch (error) {
- console.error('获取套餐图标数据失败', error)
- }
- },
- // 获取云机分组标识号
- async getCloudGroupId() {
- try {
- const result = await this.$axios.get('/resources/v6/client/group/list');
- if(result.status === 200 && result.data.status === 0 && result.data.success) {
- // 统计所有分组的云机数量
- let count = result.data.data.reduce((pre, g) => {
- // 组合分组名称和数量
- g.label = `${g.groupName}(${g.groupCount})`;
- // 统计所有分组的云机数量
- return pre + g.groupCount;
- }, 0);
- result.data.data.unshift({
- id: -1, // -1 全部分组(前端自定义值) -10 被授权列表 0 未分组
- groupName: '全部分组',
- groupCount: count,
- label: `全部分组(${count})`,
- })
- this.groupList = result.data.data;
- }
- } catch (error) {
-
- }
- }
- }
- }
|