Commit ae50a3b8eb3701fef2f0b7a8dda133d40bc590eb

Authored by xp.Huang
2 parents 0395931d 02ed73f5

Merge branch 'local_dev_ft' into 'main'

pref:优化app端

See merge request huang/thingskit-app!98
  1 +{
  2 + "prompt" : "none"
  3 +}
... ...
1 1 import base from "@/config/baseUrl";
2 2 import store from "@/store";
3   -import { judgeLogin } from "@/config/login";
  3 +import {
  4 + judgeLogin
  5 +} from "@/config/login";
4 6
5 7 // 初始化请求配置
6 8 uni.$u.http.setConfig((config) => {
7   - const token =
8   - store.state.userInfo.isToken ||
9   - uni.getStorageSync("userInfo").isToken ||
10   - undefined;
11   - // #ifdef H5
12   - window.sessionStorage.getItem("userInfo").isToken;
13   - // #endif
14   - /* config 为默认全局配置*/
15   - // const getConfiguration = uni.getStorageSync('getConfiguration').isConfiguration
16   - // console.log('getConfiguration', getConfiguration);
17   - // config.baseURL = getConfiguration == true ? base.baseDrawioUrl : base.baseUrl /* 根域名 */
18   - config.baseURL = base.baseUrl; /* 根域名 */
19   - config.header = {
20   - "Content-Type": "application/json",
21   - "X-Authorization": "Bearer " + token,
22   - };
23   - config.custom = {
24   - load: true, //是否显示加载动画
25   - isFactory: true, //true:返回的数据成功只返回data false:返回response
26   - catch: true, //默认数据返回不成功进入catch返回
27   - auth: true, //token
28   - };
29   - return config;
  9 + const token =
  10 + store.state.userInfo.isToken ||
  11 + uni.getStorageSync("userInfo").isToken ||
  12 + undefined;
  13 + // #ifdef H5
  14 + window.sessionStorage.getItem("userInfo").isToken;
  15 + // #endif
  16 + /* config 为默认全局配置*/
  17 + // const getConfiguration = uni.getStorageSync('getConfiguration').isConfiguration
  18 + // console.log('getConfiguration', getConfiguration);
  19 + // config.baseURL = getConfiguration == true ? base.baseDrawioUrl : base.baseUrl /* 根域名 */
  20 + config.baseURL = base.baseUrl; /* 根域名 */
  21 + config.header = {
  22 + "Content-Type": "application/json",
  23 + "X-Authorization": "Bearer " + token,
  24 + };
  25 + config.custom = {
  26 + load: true, //是否显示加载动画
  27 + isFactory: true, //true:返回的数据成功只返回data false:返回response
  28 + catch: true, //默认数据返回不成功进入catch返回
  29 + auth: true, //token
  30 + };
  31 + return config;
30 32 });
31 33
32 34 // 请求拦截
33 35 uni.$u.http.interceptors.request.use(
34   - (config) => {
35   - if (store.state.userInfo.isThirdLogin) {
36   - uni.switchTab({
37   - url: "../pages/personal/personal",
38   - });
39   - }
40   - // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{}
41   - config.data = config.data || {};
42   - // 根据custom参数中配置的是否需要token,添加对应的请求头
43   - const getConfiguration =
44   - uni.getStorageSync("getConfiguration").isConfiguration;
45   - if (config?.custom?.auth) {
46   - config.header["X-Authorization"] =
47   - "Bearer " + store.state.userInfo.isToken ||
48   - uni.getStorageSync("userInfo").isToken ||
49   - undefined;
50   - config.baseURL =
51   - getConfiguration == true ? base.baseDrawioUrl : base.baseUrl;
52   - }
53   - if (config?.custom?.load) {
54   - //打开加载动画
55   - store.commit("setLoadingShow", true);
56   - }
57   - if (getConfiguration) {
58   - uni.setStorageSync("config", config);
59   - } else {
60   - uni.removeStorageSync("config");
61   - }
62   - return config;
63   - },
64   - (config) => {
65   - return Promise.reject(config);
66   - }
  36 + (config) => {
  37 + if (store.state.userInfo.isThirdLogin) {
  38 + uni.switchTab({
  39 + url: "../pages/personal/personal",
  40 + });
  41 + }
  42 + // 初始化请求拦截器时,会执行此方法,此时data为undefined,赋予默认{}
  43 + config.data = config.data || {};
  44 + // 根据custom参数中配置的是否需要token,添加对应的请求头
  45 + const getConfiguration =
  46 + uni.getStorageSync("getConfiguration").isConfiguration;
  47 + if (config?.custom?.auth) {
  48 + config.header["X-Authorization"] =
  49 + "Bearer " + store.state.userInfo.isToken ||
  50 + uni.getStorageSync("userInfo").isToken ||
  51 + undefined;
  52 + config.baseURL =
  53 + getConfiguration == true ? base.baseDrawioUrl : base.baseUrl;
  54 + }
  55 + if (config?.custom?.load) {
  56 + //打开加载动画
  57 + store.commit("setLoadingShow", true);
  58 + }
  59 + if (getConfiguration) {
  60 + uni.setStorageSync("config", config);
  61 + } else {
  62 + uni.removeStorageSync("config");
  63 + }
  64 + return config;
  65 + },
  66 + (config) => {
  67 + return Promise.reject(config);
  68 + }
67 69 );
68 70
69 71 // 响应拦截
70 72 uni.$u.http.interceptors.response.use(
71   - (response) => {
72   - // 关闭加载动画
73   - store.commit("setLoadingShow", false);
74   - const data = response.data;
75   - const custom = response.config?.custom;
76   - // code: 200、请求成功 其他,没有更多参数 401、被迫下线重新登录、
77   - if (response.statusCode == 200) {
78   - return Promise.resolve(data);
79   - } else if (response.statusCode == 401) {
80   - // 清空登录信息
81   - store.commit("emptyUserInfo");
82   - // 20秒节流,弹窗登录
83   - uni.$u.throttle(judgeLogin(), 20000);
84   - return new Promise(() => {});
85   - } else {
86   - }
87   - },
88   - (response) => {
89   - // 关闭加载动画
90   - store.commit("setLoadingShow", false);
91   - let show = true;
92   - let errorData = "请检查网络或服务器";
93   - let message =
94   - response.data?.message || response.data?.msg || response?.errMsg;
95   - if (message == "request:fail url not in domain list") {
96   - errorData = "检查请求域名是否添加了域名白名单";
97   - } else if (message == "request:fail timeout") {
98   - errorData = "请求超时:请检查网络";
99   - } else if (response.data.status == 401) {
100   - const isLoginFlag = uni.getStorageSync("userInfo");
101   - if (!store.state.userInfo.isThirdLogin) {
102   - const routers = getCurrentPages();
103   - const currentRoute = routers[routers.length - 1].route;
104   - const isLoginPage = currentRoute.includes(
105   - "publicLoginSubPage/public/login"
106   - );
107   - !isLoginPage &&
108   - uni.reLaunch({
109   - url: "/publicLoginSubPage/public/login",
110   - });
111   - // 清空登录信息
112   - store.commit("emptyUserInfo");
113   - show = false;
114   - } else {
115   - uni.switchTab({
116   - url: "../pages/personal/personal",
117   - });
118   - show = false;
119   - }
120   - } else if (message == "request:ok") {
121   - show = false;
122   - errorData = "";
123   - } else {
124   - errorData = message || "";
125   - }
126   - if (show) uni.$u.toast(errorData);
127   - return Promise.reject(response);
128   - }
129   -);
  73 + (response) => {
  74 + // 关闭加载动画
  75 + store.commit("setLoadingShow", false);
  76 + const data = response.data;
  77 + const custom = response.config?.custom;
  78 + // code: 200、请求成功 其他,没有更多参数 401、被迫下线重新登录、
  79 + if (response.statusCode == 200) {
  80 + return Promise.resolve(data);
  81 + } else if (response.statusCode == 401) {
  82 + // 清空登录信息
  83 + store.commit("emptyUserInfo");
  84 + // 20秒节流,弹窗登录
  85 + uni.$u.throttle(judgeLogin(), 20000);
  86 + return new Promise(() => {});
  87 + } else {}
  88 + },
  89 + (response) => {
  90 + // 关闭加载动画
  91 + store.commit("setLoadingShow", false);
  92 + let show = true;
  93 + let errorData = "请检查网络或服务器";
  94 + let message =
  95 + response.data?.message || response.data?.msg || response?.errMsg;
  96 + if (message == "request:fail url not in domain list") {
  97 + errorData = "检查请求域名是否添加了域名白名单";
  98 + } else if (message == "request:fail timeout") {
  99 + errorData = "请求超时:请检查网络";
  100 + } else if (response.data.status == 401) {
  101 + const isLoginFlag = uni.getStorageSync("userInfo");
  102 + if (!store.state.userInfo.isThirdLogin) {
  103 + const routers = getCurrentPages();
  104 + const currentRoute = routers[routers.length - 1].route;
  105 + const isLoginPage = currentRoute.includes(
  106 + "publicLoginSubPage/public/login"
  107 + );
  108 + !isLoginPage &&
  109 + uni.reLaunch({
  110 + url: "/publicLoginSubPage/public/login",
  111 + });
  112 + // 清空登录信息
  113 + store.commit("emptyUserInfo");
  114 + show = false;
  115 + } else {
  116 + uni.switchTab({
  117 + url: "../pages/personal/personal",
  118 + });
  119 + show = false;
  120 + }
  121 + } else if (message == "request:ok") {
  122 + show = false;
  123 + errorData = "";
  124 + } else {
  125 + errorData = message || "";
  126 + }
  127 + // console.log('errorData', errorData);
  128 + uni.$u.toast(message);
  129 + // if (show) uni.$u.toast(errorData);
  130 + return Promise.reject(response);
  131 + }
  132 +);
... ...
... ... @@ -24,7 +24,7 @@
24 24 <view class="info" style="margin-top: 15rpx;background: rgba(1, 1, 1, 0);">
25 25 <view class="info-contain">
26 26 <u-form-item label="图片" prop="feedbackInfo.images" borderBottom ref="item1">
27   - <u-upload :sizeType="compressed" :fileList="fileList1" @afterRead="afterRead"
  27 + <u-upload :capture="capture" :fileList="fileList1" @afterRead="afterRead"
28 28 @delete="deletePic" name="1" multiple :maxCount="6"></u-upload>
29 29 </u-form-item>
30 30 </view>
... ... @@ -57,6 +57,7 @@
57 57 export default {
58 58 data() {
59 59 return {
  60 + capture: ['album'],
60 61 feedbackData: {
61 62 feedbackInfo: {
62 63 title: '',
... ...
  1 +/**
  2 + * 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启
  3 + */
  4 +
  5 +var isIos
  6 +// #ifdef APP-PLUS
  7 +isIos = (plus.os.name == "iOS")
  8 +// #endif
  9 +
  10 +// 判断推送权限是否开启
  11 +function judgeIosPermissionPush() {
  12 + var result = false;
  13 + var UIApplication = plus.ios.import("UIApplication");
  14 + var app = UIApplication.sharedApplication();
  15 + var enabledTypes = 0;
  16 + if (app.currentUserNotificationSettings) {
  17 + var settings = app.currentUserNotificationSettings();
  18 + enabledTypes = settings.plusGetAttribute("types");
  19 + console.log("enabledTypes1:" + enabledTypes);
  20 + if (enabledTypes == 0) {
  21 + console.log("推送权限没有开启");
  22 + } else {
  23 + result = true;
  24 + console.log("已经开启推送功能!")
  25 + }
  26 + plus.ios.deleteObject(settings);
  27 + } else {
  28 + enabledTypes = app.enabledRemoteNotificationTypes();
  29 + if (enabledTypes == 0) {
  30 + console.log("推送权限没有开启!");
  31 + } else {
  32 + result = true;
  33 + console.log("已经开启推送功能!")
  34 + }
  35 + console.log("enabledTypes2:" + enabledTypes);
  36 + }
  37 + plus.ios.deleteObject(app);
  38 + plus.ios.deleteObject(UIApplication);
  39 + return result;
  40 +}
  41 +
  42 +// 判断定位权限是否开启
  43 +function judgeIosPermissionLocation() {
  44 + var result = false;
  45 + var cllocationManger = plus.ios.import("CLLocationManager");
  46 + var status = cllocationManger.authorizationStatus();
  47 + result = (status != 2)
  48 + console.log("定位权限开启:" + result);
  49 + // 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation
  50 + /* var enable = cllocationManger.locationServicesEnabled();
  51 + var status = cllocationManger.authorizationStatus();
  52 + console.log("enable:" + enable);
  53 + console.log("status:" + status);
  54 + if (enable && status != 2) {
  55 + result = true;
  56 + console.log("手机定位服务已开启且已授予定位权限");
  57 + } else {
  58 + console.log("手机系统的定位没有打开或未给予定位权限");
  59 + } */
  60 + plus.ios.deleteObject(cllocationManger);
  61 + return result;
  62 +}
  63 +
  64 +// 判断麦克风权限是否开启
  65 +function judgeIosPermissionRecord() {
  66 + var result = false;
  67 + var avaudiosession = plus.ios.import("AVAudioSession");
  68 + var avaudio = avaudiosession.sharedInstance();
  69 + var permissionStatus = avaudio.recordPermission();
  70 + console.log("permissionStatus:" + permissionStatus);
  71 + if (permissionStatus == 1684369017 || permissionStatus == 1970168948) {
  72 + console.log("麦克风权限没有开启");
  73 + } else {
  74 + result = true;
  75 + console.log("麦克风权限已经开启");
  76 + }
  77 + plus.ios.deleteObject(avaudiosession);
  78 + return result;
  79 +}
  80 +
  81 +// 判断相机权限是否开启
  82 +function judgeIosPermissionCamera() {
  83 + var result = false;
  84 + var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
  85 + var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
  86 + console.log("authStatus:" + authStatus);
  87 + if (authStatus == 3) {
  88 + result = true;
  89 + console.log("相机权限已经开启");
  90 + } else {
  91 + console.log("相机权限没有开启");
  92 + }
  93 + plus.ios.deleteObject(AVCaptureDevice);
  94 + return result;
  95 +}
  96 +
  97 +// 判断相册权限是否开启
  98 +function judgeIosPermissionPhotoLibrary() {
  99 + var result = false;
  100 + var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary");
  101 + var authStatus = PHPhotoLibrary.authorizationStatus();
  102 + console.log("authStatus:" + authStatus);
  103 + if (authStatus == 3) {
  104 + result = true;
  105 + console.log("相册权限已经开启");
  106 + } else {
  107 + console.log("相册权限没有开启");
  108 + }
  109 + plus.ios.deleteObject(PHPhotoLibrary);
  110 + return result;
  111 +}
  112 +
  113 +// 判断通讯录权限是否开启
  114 +function judgeIosPermissionContact() {
  115 + var result = false;
  116 + var CNContactStore = plus.ios.import("CNContactStore");
  117 + var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0);
  118 + if (cnAuthStatus == 3) {
  119 + result = true;
  120 + console.log("通讯录权限已经开启");
  121 + } else {
  122 + console.log("通讯录权限没有开启");
  123 + }
  124 + plus.ios.deleteObject(CNContactStore);
  125 + return result;
  126 +}
  127 +
  128 +// 判断日历权限是否开启
  129 +function judgeIosPermissionCalendar() {
  130 + var result = false;
  131 + var EKEventStore = plus.ios.import("EKEventStore");
  132 + var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0);
  133 + if (ekAuthStatus == 3) {
  134 + result = true;
  135 + console.log("日历权限已经开启");
  136 + } else {
  137 + console.log("日历权限没有开启");
  138 + }
  139 + plus.ios.deleteObject(EKEventStore);
  140 + return result;
  141 +}
  142 +
  143 +// 判断备忘录权限是否开启
  144 +function judgeIosPermissionMemo() {
  145 + var result = false;
  146 + var EKEventStore = plus.ios.import("EKEventStore");
  147 + var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1);
  148 + if (ekAuthStatus == 3) {
  149 + result = true;
  150 + console.log("备忘录权限已经开启");
  151 + } else {
  152 + console.log("备忘录权限没有开启");
  153 + }
  154 + plus.ios.deleteObject(EKEventStore);
  155 + return result;
  156 +}
  157 +
  158 +// Android权限查询
  159 +function requestAndroidPermission(permissionID) {
  160 + return new Promise((resolve, reject) => {
  161 + plus.android.requestPermissions(
  162 + [permissionID], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
  163 + function(resultObj) {
  164 + var result = 0;
  165 + for (var i = 0; i < resultObj.granted.length; i++) {
  166 + var grantedPermission = resultObj.granted[i];
  167 + console.log('已获取的权限:' + grantedPermission);
  168 + result = 1
  169 + }
  170 + for (var i = 0; i < resultObj.deniedPresent.length; i++) {
  171 + var deniedPresentPermission = resultObj.deniedPresent[i];
  172 + console.log('拒绝本次申请的权限:' + deniedPresentPermission);
  173 + result = 0
  174 + }
  175 + for (var i = 0; i < resultObj.deniedAlways.length; i++) {
  176 + var deniedAlwaysPermission = resultObj.deniedAlways[i];
  177 + console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
  178 + result = -1
  179 + }
  180 + resolve(result);
  181 + // 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
  182 + // if (result != 1) {
  183 + // gotoAppPermissionSetting()
  184 + // }
  185 + },
  186 + function(error) {
  187 + console.log('申请权限错误:' + error.code + " = " + error.message);
  188 + resolve({
  189 + code: error.code,
  190 + message: error.message
  191 + });
  192 + }
  193 + );
  194 + });
  195 +}
  196 +
  197 +// 使用一个方法,根据参数判断权限
  198 +function judgeIosPermission(permissionID) {
  199 + if (permissionID == "location") {
  200 + return judgeIosPermissionLocation()
  201 + } else if (permissionID == "camera") {
  202 + return judgeIosPermissionCamera()
  203 + } else if (permissionID == "photoLibrary") {
  204 + return judgeIosPermissionPhotoLibrary()
  205 + } else if (permissionID == "record") {
  206 + return judgeIosPermissionRecord()
  207 + } else if (permissionID == "push") {
  208 + return judgeIosPermissionPush()
  209 + } else if (permissionID == "contact") {
  210 + return judgeIosPermissionContact()
  211 + } else if (permissionID == "calendar") {
  212 + return judgeIosPermissionCalendar()
  213 + } else if (permissionID == "memo") {
  214 + return judgeIosPermissionMemo()
  215 + }
  216 + return false;
  217 +}
  218 +
  219 +// 跳转到**应用**的权限页面
  220 +function gotoAppPermissionSetting() {
  221 + if (isIos) {
  222 + var UIApplication = plus.ios.import("UIApplication");
  223 + var application2 = UIApplication.sharedApplication();
  224 + var NSURL2 = plus.ios.import("NSURL");
  225 + // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
  226 + var setting2 = NSURL2.URLWithString("app-settings:");
  227 + application2.openURL(setting2);
  228 +
  229 + plus.ios.deleteObject(setting2);
  230 + plus.ios.deleteObject(NSURL2);
  231 + plus.ios.deleteObject(application2);
  232 + } else {
  233 + // console.log(plus.device.vendor);
  234 + var Intent = plus.android.importClass("android.content.Intent");
  235 + var Settings = plus.android.importClass("android.provider.Settings");
  236 + var Uri = plus.android.importClass("android.net.Uri");
  237 + var mainActivity = plus.android.runtimeMainActivity();
  238 + var intent = new Intent();
  239 + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
  240 + var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
  241 + intent.setData(uri);
  242 + mainActivity.startActivity(intent);
  243 + }
  244 +}
  245 +
  246 +// 检查系统的设备服务是否开启
  247 +// var checkSystemEnableLocation = async function () {
  248 +function checkSystemEnableLocation() {
  249 + if (isIos) {
  250 + var result = false;
  251 + var cllocationManger = plus.ios.import("CLLocationManager");
  252 + var result = cllocationManger.locationServicesEnabled();
  253 + console.log("系统定位开启:" + result);
  254 + plus.ios.deleteObject(cllocationManger);
  255 + return result;
  256 + } else {
  257 + var context = plus.android.importClass("android.content.Context");
  258 + var locationManager = plus.android.importClass("android.location.LocationManager");
  259 + var main = plus.android.runtimeMainActivity();
  260 + var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  261 + var result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);
  262 + console.log("系统定位开启:" + result);
  263 + return result
  264 + }
  265 +}
  266 +
  267 +module.exports = {
  268 + judgeIosPermission: judgeIosPermission,
  269 + requestAndroidPermission: requestAndroidPermission,
  270 + checkSystemEnableLocation: checkSystemEnableLocation,
  271 + gotoAppPermissionSetting: gotoAppPermissionSetting
  272 +}
... ...
1 1 {
2   - "name" : "yun-teng-app",
3   - "appid" : "__UNI__AD0D64F",
4   - "description" : "thingskit",
5   - "versionName" : "1.0.0",
6   - "versionCode" : 100,
7   - "transformPx" : false,
8   - "app-plus" : {
9   - "usingComponents" : true,
10   - "nvueStyleCompiler" : "uni-app",
11   - "compilerVersion" : 3,
12   - "splashscreen" : {
13   - "alwaysShowBeforeRender" : false,
14   - "waiting" : false,
15   - "autoclose" : true,
16   - "delay" : 0
17   - },
18   - "modules" : {
19   - "VideoPlayer" : {},
20   - "Maps" : {},
21   - "Contacts" : {},
22   - "FaceID" : {},
23   - "Messaging" : {},
24   - "OAuth" : {},
25   - "Camera" : {}
26   - },
27   - "compatible" : {
28   - "ignoreVersion" : true
29   - },
30   - "distribute" : {
31   - "android" : {
32   - "permissions" : [
33   - "<uses-feature android:name=\"android.hardware.camera\"/>",
34   - "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
35   - "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
36   - "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
37   - "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
38   - "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
39   - "<uses-permission android:name=\"android.permission.CAMERA\"/>",
40   - "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
41   - "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
42   - "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
43   - "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
44   - "<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>",
45   - "<uses-permission android:name=\"android.permission.INTERNET\"/>",
46   - "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
47   - "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
48   - "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
49   - "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
50   - "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
51   - "<uses-permission android:name=\"android.permission.READ_SMS\"/>",
52   - "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>",
53   - "<uses-permission android:name=\"android.permission.SEND_SMS\"/>",
54   - "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
55   - "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
56   - "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
57   - "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
58   - "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
59   - "<uses-permission android:name=\"android.permission.WRITE_SMS\"/>"
60   - ],
61   - "autoSdkPermissions" : false
62   - },
63   - "ios" : {
64   - "dSYMs" : false
65   - },
66   - "sdkConfigs" : {
67   - "ad" : {},
68   - "geolocation" : {
69   - "system" : {
70   - "__platform__" : [ "ios", "android" ]
71   - },
72   - "amap" : {
73   - "__platform__" : [ "ios", "android" ],
74   - "appkey_ios" : "",
75   - "appkey_android" : ""
76   - }
77   - },
78   - "maps" : {
79   - "amap" : {
80   - "appkey_ios" : "5221d1373233c782efac82fb176f7f7d",
81   - "appkey_android" : "5221d1373233c782efac82fb176f7f7d"
82   - }
83   - },
84   - "oauth" : {
85   - "weixin" : {
86   - "appid" : "wx0ad61d7bf6808e02",
87   - "UniversalLinks" : ""
88   - }
89   - }
90   - },
91   - "splashscreen" : {
92   - "androidStyle" : "default",
93   - "android" : {}
94   - },
95   - "icons" : {
96   - "android" : {
97   - "xxhdpi" : "static/logo.png",
98   - "xhdpi" : "static/logo.png",
99   - "hdpi" : "static/logo.png",
100   - "xxxhdpi" : "static/logo.png"
101   - }
102   - }
103   - }
104   - },
105   - "quickapp" : {},
106   - "mp-weixin" : {
107   - "appid" : "wx99c411dc3c5571ef",
108   - "setting" : {
109   - "urlCheck" : false,
110   - "minified" : true,
111   - "es6" : false,
112   - "postcss" : true
113   - },
114   - "usingComponents" : true,
115   - "permission" : {
116   - "scope.userLocation" : {
117   - "desc" : "你的位置信息将用于小程序位置接口的效果展示"
118   - }
119   - },
120   - "lazyCodeLoading" : "requiredComponents",
121   - "optimization" : {
122   - "subPackages" : true
123   - }
124   - },
125   - "mp-alipay" : {
126   - "usingComponents" : true
127   - },
128   - "mp-baidu" : {
129   - "usingComponents" : true
130   - },
131   - "mp-toutiao" : {
132   - "usingComponents" : true
133   - },
134   - "uniStatistics" : {
135   - "enable" : false
136   - },
137   - "vueVersion" : "2",
138   - "h5" : {
139   - "sdkConfigs" : {
140   - "maps" : {}
141   - },
142   - "router" : {
143   - "base" : "minImage/h5/"
144   - }
145   - }
  2 + "name": "ThingsKit",
  3 + "appid": "__UNI__AD0D64F",
  4 + "description": "thingskit",
  5 + "versionName": "1.0.0",
  6 + "versionCode": 100,
  7 + "transformPx": false,
  8 + "app-plus": {
  9 + "usingComponents": true,
  10 + "nvueStyleCompiler": "uni-app",
  11 + "compilerVersion": 3,
  12 + "splashscreen": {
  13 + "alwaysShowBeforeRender": false,
  14 + "waiting": false,
  15 + "autoclose": true,
  16 + "delay": 0
  17 + },
  18 + "modules": {
  19 + "VideoPlayer": {},
  20 + "Maps": {},
  21 + "Contacts": {},
  22 + "FaceID": {},
  23 + "Messaging": {},
  24 + "OAuth": {},
  25 + "Camera": {}
  26 + },
  27 + "compatible": {
  28 + "ignoreVersion": true
  29 + },
  30 + "distribute": {
  31 + "android": {
  32 + "permissions": [
  33 + "<uses-feature android:name=\"android.hardware.camera\"/>",
  34 + "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
  35 + "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
  36 + "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
  37 + "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
  38 + "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
  39 + "<uses-permission android:name=\"android.permission.CAMERA\"/>",
  40 + "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
  41 + "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
  42 + "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
  43 + "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
  44 + "<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>",
  45 + "<uses-permission android:name=\"android.permission.INTERNET\"/>",
  46 + "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
  47 + "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
  48 + "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
  49 + "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
  50 + "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
  51 + "<uses-permission android:name=\"android.permission.READ_SMS\"/>",
  52 + "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>",
  53 + "<uses-permission android:name=\"android.permission.SEND_SMS\"/>",
  54 + "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
  55 + "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
  56 + "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
  57 + "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
  58 + "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
  59 + "<uses-permission android:name=\"android.permission.WRITE_SMS\"/>"
  60 + ],
  61 + "autoSdkPermissions": false
  62 + },
  63 + "ios": {
  64 + "dSYMs": false
  65 + },
  66 + "sdkConfigs": {
  67 + "ad": {},
  68 + "geolocation": {
  69 + "system": {
  70 + "__platform__": ["ios", "android"]
  71 + },
  72 + "amap": {
  73 + "__platform__": ["ios", "android"],
  74 + "appkey_ios": "",
  75 + "appkey_android": ""
  76 + }
  77 + },
  78 + "maps": {
  79 + "amap": {
  80 + "appkey_ios": "5221d1373233c782efac82fb176f7f7d",
  81 + "appkey_android": "5221d1373233c782efac82fb176f7f7d"
  82 + }
  83 + },
  84 + "oauth": {
  85 + "weixin": {
  86 + "appid": "wx0ad61d7bf6808e02",
  87 + "UniversalLinks": ""
  88 + }
  89 + }
  90 + },
  91 + "splashscreen": {
  92 + "androidStyle": "default",
  93 + "android": {},
  94 + "useOriginalMsgbox": false
  95 + },
  96 + "icons": {
  97 + "android": {
  98 + "xxhdpi": "static/logo.png",
  99 + "xhdpi": "static/logo.png",
  100 + "hdpi": "static/logo.png",
  101 + "xxxhdpi": "static/logo.png"
  102 + }
  103 + }
  104 + }
  105 + },
  106 + "quickapp": {},
  107 + "mp-weixin": {
  108 + "appid": "wx99c411dc3c5571ef",
  109 + "setting": {
  110 + "urlCheck": false,
  111 + "minified": true,
  112 + "es6": false,
  113 + "postcss": true
  114 + },
  115 + "usingComponents": true,
  116 + "permission": {
  117 + "scope.userLocation": {
  118 + "desc": "你的位置信息将用于小程序位置接口的效果展示"
  119 + }
  120 + },
  121 + "lazyCodeLoading": "requiredComponents",
  122 + "optimization": {
  123 + "subPackages": true
  124 + }
  125 + },
  126 + "mp-alipay": {
  127 + "usingComponents": true
  128 + },
  129 + "mp-baidu": {
  130 + "usingComponents": true
  131 + },
  132 + "mp-toutiao": {
  133 + "usingComponents": true
  134 + },
  135 + "uniStatistics": {
  136 + "enable": false
  137 + },
  138 + "vueVersion": "2",
  139 + "h5": {
  140 + "sdkConfigs": {
  141 + "maps": {}
  142 + },
  143 + "router": {
  144 + "base": "minImage/h5/"
  145 + }
  146 + },
  147 + "locale": "zh-Hans"
146 148 }
... ...
1 1 <template>
2 2 <view class="container">
3 3 <view class="container-box">
4   - <image :src="mpOwnConfig.logo ? mpOwnConfig.logo : staticLogo"></image>
  4 + <image :src="mpOwnConfig.logo"></image>
5 5 <text class="splash-text-muted">连接世界 创造价值</text>
6 6 </view>
7 7 </view>
... ... @@ -11,6 +11,8 @@
11 11 import {
12 12 mapState
13 13 } from 'vuex';
  14 + import api from '@/api/index.js'
  15 +
14 16 export default {
15 17 data() {
16 18 return {
... ... @@ -20,34 +22,33 @@
20 22 },
21 23 onLoad() {
22 24 this.getPlateForm();
  25 + },
  26 + created() {
23 27 if (!this.userInfo.isToken) {
24 28 setTimeout(() => {
25 29 uni.reLaunch({
26 30 url: '/publicLoginSubPage/public/login'
27 31 });
28   - }, 2500);
  32 + }, 1500);
29 33 } else {
30 34 setTimeout(() => {
31 35 uni.reLaunch({
32 36 url: '/pages/index/index'
33 37 });
34   - }, 2500);
  38 + }, 1500);
35 39 }
36 40 },
37 41 computed: {
38   - ...mapState(['userInfo'])
  42 + ...mapState(['userInfo']),
39 43 },
40 44 methods: {
41   - getPlateForm() {
42   - uni.$u.http.get('/yt/app_design/get').then(res => {
43   - if (res) {
44   - this.mpOwnConfig = {
45   - bg: res.background,
46   - logo: res.logo,
47   - name: res.name
48   - };
49   - }
50   - });
  45 + async getPlateForm() {
  46 + const res = await api.loginApi.getPlateCustomApi()
  47 + this.mpOwnConfig = {
  48 + bg: res.background,
  49 + logo: res.logo ? res.logo : this.staticLogo,
  50 + name: res.name
  51 + };
51 52 }
52 53 }
53 54 };
... ... @@ -69,8 +70,6 @@
69 70 width: 100rpx;
70 71 height: 100rpx;
71 72 }
72   -
73   - text {}
74 73 }
75 74 }
76 75 </style>
... ...
... ... @@ -2,6 +2,7 @@
2 2 <view class="set-page">
3 3 <!-- 公共组件-每个页面必须引入 -->
4 4 <public-module></public-module>
  5 + <!-- #ifdef MP-WEIXIN -->
5 6 <view @click="upAvatar" class="u-flex set-main">
6 7 <view class="main-image">
7 8 <image class="image" :src="avatar || '../../static/logo.png'"></image>
... ... @@ -10,6 +11,17 @@
10 11 <image class="image" src="../../static/arrow-right.png"></image>
11 12 </view>
12 13 </view>
  14 + <!-- #endif -->
  15 + <!-- #ifdef APP-PLUS -->
  16 + <view @click="upAppAvatar" class="u-flex set-main">
  17 + <view class="main-image">
  18 + <image class="image" :src="avatar || '../../static/logo.png'"></image>
  19 + </view>
  20 + <view class="main-right-image">
  21 + <image class="image" src="../../static/arrow-right.png"></image>
  22 + </view>
  23 + </view>
  24 + <!-- #endif -->
13 25 <view class="u-m-t-20 basic-text"><text class="text">基本资料</text></view>
14 26 <view class="basic-main">
15 27 <u--form labelPosition="left" :model="myInfoModel" ref="myForm">
... ... @@ -63,6 +75,8 @@
63 75 </u-popup>
64 76 </view>
65 77 <!-- 解绑账号 -->
  78 + <u-picker :show="showSelectType" :columns="avgColumns" keyName="label" closeOnClickOverlay
  79 + @confirm="confirmAvgGap" @cancel="showSelectType=false" @close="showSelectType=false"></u-picker>
66 80 </view>
67 81 </template>
68 82
... ... @@ -75,10 +89,21 @@
75 89 mapState
76 90 } from 'vuex';
77 91 import api from '@/api/index.js'
  92 + import permission from '@/js_sdk/wa-permission/permission.js'
78 93
79 94 export default {
80 95 data() {
81 96 return {
  97 + avgColumns: [
  98 + [{
  99 + label: '相机',
  100 + value: 1
  101 + }, {
  102 + label: '相册',
  103 + value: 2
  104 + }, ]
  105 + ],
  106 + showSelectType: false,
82 107 showBind: false,
83 108 PrimaryColor: '#377DFF', //主题色
84 109 InfoColor: '#00C9A7', //主题色
... ... @@ -119,14 +144,14 @@
119 144 info: {},
120 145 openIds: '',
121 146 isUpdatePersonOrLoginInfo: false,
122   - isJudgeBindBtn: true
  147 + isJudgeBindBtn: true,
  148 + modify_content: ''
123 149 };
124 150 },
125 151 onReady() {
126 152 this.$refs.myForm.setRules(this.rules);
127 153 },
128 154 onLoad(e) {
129   - console.log(e);
130 155 if (e.data !== null) {
131 156 let params = JSON.parse(e.data);
132 157 this.info = params;
... ... @@ -150,7 +175,103 @@
150 175 ...mapState(['userInfo'])
151 176 },
152 177 methods: {
  178 + modify() {
  179 + uni.showModal({
  180 + title: '需要下列权限才可以正常使用',
  181 + content: this.modify_content,
  182 + confirmText: '前往开启',
  183 + success: function(res) {
  184 + if (res.confirm) {
  185 + permission.gotoAppPermissionSetting(); //动态修改权限
  186 + }
  187 + }
  188 + });
  189 + },
  190 + async requestAndroidPermission(permissionID, e) {
  191 + let resp = await permission.requestAndroidPermission(permissionID, e);
  192 + if (resp == -1) {
  193 + this.modify();
  194 + } else if (resp == 1) {
  195 + if (e == 1) {
  196 + this.chooseImage1()
  197 + } else {
  198 + this.chooseImage2()
  199 + }
  200 + }
  201 + },
153 202 ...mapMutations(['setUserInfo', 'emptyUserInfo']),
  203 + chooseImage1() {
  204 + let token;
  205 + token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined;
  206 + // #ifdef H5
  207 + token = window.sessionStorage.getItem('userInfo').isToken;
  208 + // #endif
  209 + if (!token) return uni.$u.toast('请登录后上传图片');
  210 + var cmr = plus.camera.getCamera();
  211 + var res = cmr.supportedImageResolutions[0];
  212 + var fmt = cmr.supportedImageFormats[0];
  213 + cmr.captureImage(
  214 + (path) => {
  215 + this.showSelectType = false
  216 + uni.uploadFile({
  217 + url: `${baseUrl.baseUrl}/yt/oss/upload`,
  218 + filePath: path,
  219 + name: 'file',
  220 + header: {
  221 + 'content-type': 'multipart/form-data',
  222 + Authorization: 'Bearer ' + token
  223 + },
  224 + formData: {},
  225 + success: res => {
  226 + let objImage = JSON.parse(res.data);
  227 + this.avatar = objImage.fileStaticUri;
  228 + uni.$u.toast('头像上传成功');
  229 + }
  230 + });
  231 + },
  232 + function(error) {
  233 + console.log('Capture image failed: ' + error.message);
  234 + }, {
  235 + resolution: res,
  236 + format: fmt
  237 + }
  238 + );
  239 + },
  240 + //选择相册
  241 + chooseImage2() {
  242 + let token;
  243 + token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined;
  244 + // #ifdef H5
  245 + token = window.sessionStorage.getItem('userInfo').isToken;
  246 + // #endif
  247 + if (!token) return uni.$u.toast('请登录后上传图片');
  248 + plus.gallery.pick(
  249 + (path) => {
  250 + console.log(path)
  251 + this.showSelectType = false
  252 + uni.uploadFile({
  253 + url: `${baseUrl.baseUrl}/yt/oss/upload`,
  254 + filePath: path,
  255 + name: 'file',
  256 + header: {
  257 + 'content-type': 'multipart/form-data',
  258 + Authorization: 'Bearer ' + token
  259 + },
  260 + formData: {},
  261 + success: res => {
  262 + let objImage = JSON.parse(res.data);
  263 + this.avatar = objImage.fileStaticUri;
  264 + uni.$u.toast('头像上传成功');
  265 + }
  266 + });
  267 + },
  268 + function(e) {
  269 + console.log('取消选择图片');
  270 + }, {
  271 + filter: 'image'
  272 + }
  273 + );
  274 + },
154 275 confrimBind(e) {
155 276 if (e) {
156 277 //解绑
... ... @@ -181,8 +302,32 @@
181 302 clearAccountFunc() {
182 303 this.showBind = true;
183 304 },
  305 + upAppAvatar() {
  306 + this.showSelectType = true
  307 + },
  308 + confirmAvgGap(e) {
  309 + if (e.value[0].value == 1) {
  310 + this.modify_content = '摄像头权限(拍摄头像)';
  311 + //相机
  312 + switch (uni.getSystemInfoSync().platform) {
  313 + case 'android':
  314 + this.requestAndroidPermission('android.permission.CAMERA', 1);
  315 + break;
  316 + }
  317 + } else {
  318 + this.modify_content = '存储权限(读取相册)';
  319 + //相册
  320 + switch (uni.getSystemInfoSync().platform) {
  321 + case 'android':
  322 + this.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE', 2);
  323 + break;
  324 + }
  325 + }
  326 + this.showSelectAvg = false
  327 + },
184 328 // 修改头像
185 329 async upAvatar() {
  330 + let that = this
186 331 let token;
187 332 token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined;
188 333 // #ifdef H5
... ... @@ -191,6 +336,7 @@
191 336 if (!token) return uni.$u.toast('请登录后上传图片');
192 337 uni.chooseImage({
193 338 count: 1,
  339 + sizeType: ['compressed'],
194 340 sourceType: ['camera', 'album'],
195 341 success: res => {
196 342 const tempFilePaths = res.tempFilePaths;
... ... @@ -232,7 +378,7 @@
232 378 uni.$u.toast('头像上传成功');
233 379 }
234 380 });
235   - }
  381 + },
236 382 });
237 383 },
238 384 onSubmitFunc() {
... ...