util.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. import {
  11. TOKENNAME,
  12. HTTP_REQUEST_URL
  13. } from '../config/app.js';
  14. import store from '../store';
  15. import {
  16. customerType
  17. } from '@/api/api.js'
  18. // #ifdef APP-PLUS
  19. import permision from "./permission.js"
  20. // #endif
  21. export default {
  22. /**
  23. * opt object | string
  24. * to_url object | string
  25. * 例:
  26. * this.Tips('/pages/test/test'); 跳转不提示
  27. * this.Tips({title:'提示'},'/pages/test/test'); 提示并跳转
  28. * this.Tips({title:'提示'},{tab:1,url:'/pages/index/index'}); 提示并跳转值table上
  29. * tab=1 一定时间后跳转至 table上
  30. * tab=2 一定时间后跳转至非 table上
  31. * tab=3 一定时间后返回上页面
  32. * tab=4 关闭所有页面,打开到应用内的某个页面
  33. * tab=5 关闭当前页面,跳转到应用内的某个页面
  34. */
  35. Tips: function(opt, to_url) {
  36. if (typeof opt == 'string') {
  37. to_url = opt;
  38. opt = {};
  39. }
  40. let title = opt.title || '',
  41. icon = opt.icon || 'none',
  42. endtime = opt.endtime || 2000,
  43. success = opt.success;
  44. if (title) uni.showToast({
  45. title: title,
  46. icon: icon,
  47. duration: endtime,
  48. success
  49. })
  50. if (to_url != undefined) {
  51. if (typeof to_url == 'object') {
  52. let tab = to_url.tab || 1,
  53. url = to_url.url || '';
  54. switch (tab) {
  55. case 1:
  56. //一定时间后跳转至 table
  57. setTimeout(function() {
  58. uni.navigateTo({
  59. url: url
  60. })
  61. }, endtime);
  62. break;
  63. case 2:
  64. //跳转至非table页面
  65. setTimeout(function() {
  66. uni.navigateTo({
  67. url: url,
  68. })
  69. }, endtime);
  70. break;
  71. case 3:
  72. //返回上页面
  73. setTimeout(function() {
  74. // #ifndef H5
  75. uni.navigateBack({
  76. delta: parseInt(url),
  77. })
  78. // #endif
  79. // #ifdef H5
  80. history.back();
  81. // #endif
  82. }, endtime);
  83. break;
  84. case 4:
  85. //关闭所有页面,打开到应用内的某个页面
  86. setTimeout(function() {
  87. uni.reLaunch({
  88. url: url,
  89. })
  90. }, endtime);
  91. break;
  92. case 5:
  93. //关闭当前页面,跳转到应用内的某个页面
  94. setTimeout(function() {
  95. uni.redirectTo({
  96. url: url,
  97. })
  98. }, endtime);
  99. break;
  100. }
  101. } else if (typeof to_url == 'function') {
  102. setTimeout(function() {
  103. to_url && to_url();
  104. }, endtime);
  105. } else {
  106. //没有提示时跳转不延迟
  107. setTimeout(function() {
  108. uni.navigateTo({
  109. url: to_url,
  110. })
  111. }, title ? endtime : 0);
  112. }
  113. }
  114. },
  115. // 处理价格
  116. HandlePrice: function(num, type) {
  117. let obj = []
  118. if (typeof num == 'number') {
  119. obj = num.toString().split(".");
  120. } else {
  121. obj = num.split(".");
  122. }
  123. if (type) {
  124. if (obj.length) {
  125. return '.' + obj[1];
  126. } else {
  127. return ''
  128. }
  129. } else {
  130. return obj[0];
  131. }
  132. },
  133. // 将网络图片转化为base64
  134. getBase64Image: function(imageUrl) {
  135. return new Promise((resolve, reject) => {
  136. uni.request({
  137. url: imageUrl, // 服务器图片地址
  138. responseType: 'arraybuffer', // 设置响应类型为arraybuffer以接收二进制数据
  139. success: (res) => {
  140. let base64Image = 'data:image/jpeg;base64,' + uni.arrayBufferToBase64(res
  141. .data);
  142. resolve(base64Image);
  143. },
  144. fail: (err) => {
  145. reject(err);
  146. }
  147. });
  148. });
  149. },
  150. // 计算头部自定义导航高度;
  151. getWXStatusHeight() {
  152. // 获取距上
  153. const barTop = uni.getSystemInfoSync().statusBarHeight;
  154. // #ifdef MP
  155. // 获取胶囊按钮位置信息
  156. const menuButtonInfo = wx.getMenuButtonBoundingClientRect() || 0
  157. // 获取导航栏高度
  158. const barHeight = menuButtonInfo.height + (menuButtonInfo.top - barTop) * 2
  159. let barWidth = menuButtonInfo.width
  160. // #endif
  161. // #ifndef MP
  162. // 获取导航栏高度
  163. const barHeight = parseInt(barTop) + 10;
  164. let barWidth = '100%'
  165. // #endif
  166. return {
  167. barHeight,
  168. barTop,
  169. barWidth
  170. }
  171. },
  172. /**
  173. * 省市区地址分解
  174. */
  175. addressInfo: function(str) {
  176. let reg = /.+?(省|市|自治区|自治州|行政区|盟|旗|县|区)/g // 省市区的正则
  177. const area = str.match(reg) // 分割省市区
  178. let citys = ['北京市', '天津市', '上海市', '重庆市']
  179. let address_component = {
  180. city: "",
  181. district: "",
  182. province: area[0]
  183. }
  184. if (citys.indexOf(area[0]) == -1) {
  185. address_component.city = area[1]
  186. address_component.district = area[2]
  187. } else {
  188. address_component.city = area[0]
  189. address_component.district = area[1]
  190. }
  191. return address_component
  192. },
  193. /**
  194. * 跳转路径封装函数
  195. * @param url 跳转路径
  196. * 选择跳转到其他小程序时,在h5也可以跳转路径
  197. */
  198. JumpPath: function(url) {
  199. let arr = url.split('@APPID=');
  200. if (arr.length > 1) {
  201. //#ifdef MP
  202. uni.navigateToMiniProgram({
  203. appId: arr[arr.length - 1], // 此为生活缴费appid
  204. path: arr[0], // 此为生活缴费首页路径
  205. envVersion: "release",
  206. success: res => {
  207. console.log("打开成功", res);
  208. },
  209. fail: err => {
  210. console.log('sgdhgf', err);
  211. }
  212. })
  213. //#endif
  214. //#ifndef MP
  215. this.Tips({
  216. title: 'h5与app端不支持跳转外部小程序'
  217. });
  218. //#endif
  219. } else {
  220. if (url == '/pages/short_video/appSwiper/index' || url == '/pages/short_video/nvueSwiper/index') {
  221. //#ifdef APP
  222. url = '/pages/short_video/appSwiper/index'
  223. //#endif
  224. //#ifndef APP
  225. url = '/pages/short_video/nvueSwiper/index'
  226. //#endif
  227. }
  228. if (url.indexOf("http") != -1) {
  229. // #ifdef H5
  230. location.href = url;
  231. // #endif
  232. // #ifdef MP || APP-PLUS
  233. uni.navigateTo({
  234. url: `/pages/annex/web_view/index?url=${url}`
  235. });
  236. // #endif
  237. } else {
  238. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index',
  239. '/pages/index/index'
  240. ]
  241. .indexOf(url) == -1) {
  242. uni.navigateTo({
  243. url: url
  244. })
  245. } else {
  246. uni.reLaunch({
  247. url: url
  248. })
  249. }
  250. }
  251. }
  252. },
  253. /**
  254. * 移除数组中的某个数组并组成新的数组返回
  255. * @param array array 需要移除的数组
  256. * @param int index 需要移除的数组的键值
  257. * @param string | int 值
  258. * @return array
  259. *
  260. */
  261. ArrayRemove: function(array, index, value) {
  262. const valueArray = [];
  263. if (array instanceof Array) {
  264. for (let i = 0; i < array.length; i++) {
  265. if (typeof index == 'number' && array[index] != i) {
  266. valueArray.push(array[i]);
  267. } else if (typeof index == 'string' && array[i][index] != value) {
  268. valueArray.push(array[i]);
  269. }
  270. }
  271. }
  272. return valueArray;
  273. },
  274. /**
  275. * 生成海报获取文字
  276. * @param string text 为传入的文本
  277. * @param int num 为单行显示的字节长度
  278. * @return array
  279. */
  280. textByteLength: function(text, num) {
  281. let strLength = 0;
  282. let rows = 1;
  283. let str = 0;
  284. let arr = [];
  285. for (let j = 0; j < text.length; j++) {
  286. if (text.charCodeAt(j) > 255) {
  287. strLength += 2;
  288. if (strLength > rows * num) {
  289. strLength++;
  290. arr.push(text.slice(str, j));
  291. str = j;
  292. rows++;
  293. }
  294. } else {
  295. strLength++;
  296. if (strLength > rows * num) {
  297. arr.push(text.slice(str, j));
  298. str = j;
  299. rows++;
  300. }
  301. }
  302. }
  303. arr.push(text.slice(str, text.length));
  304. return [strLength, arr, rows] // [处理文字的总字节长度,每行显示内容的数组,行数]
  305. },
  306. /**
  307. * 获取分享海报
  308. * @param array arr2 海报素材
  309. * @param string store_name 素材文字
  310. * @param string price 价格
  311. * @param string ot_price 原始价格
  312. * @param function successFn 回调函数
  313. *
  314. *
  315. */
  316. PosterCanvas: function(fontColor, themeColor, siteName, arr2, store_name, price, ot_price, posterTitle, successFn) {
  317. let that = this;
  318. // uni.showLoading({
  319. // title: '海报生成中',
  320. // mask: true
  321. // });
  322. const ctx = uni.createCanvasContext('myCanvas');
  323. ctx.clearRect(0, 0, 0, 0);
  324. /**
  325. * 只能获取合法域名下的图片信息,本地调试无法获取
  326. *
  327. */
  328. ctx.fillStyle = '#fff';
  329. ctx.fillRect(0, 0, 750, 1306);
  330. uni.getImageInfo({
  331. src: arr2[0],
  332. success: function(res) {
  333. const WIDTH = res.width;
  334. // const HEIGHT = res.height;
  335. // ctx.drawImage(arr2[0], 0, 0, WIDTH, 1050);
  336. ctx.save();
  337. ctx.setFillStyle(themeColor);
  338. ctx.fillRect(0, 0, WIDTH, 108);
  339. ctx.setFontSize(33)
  340. ctx.setFillStyle('#fff');
  341. ctx.setTextAlign('center');
  342. ctx.fillText(posterTitle, WIDTH / 2, 65);
  343. ctx.save();
  344. ctx.drawImage(arr2[1], 32, 141, 685, 685);
  345. ctx.save();
  346. // ctx.setFillStyle(themeColor);
  347. // ctx.fillRect(32, 847, 85, 40);
  348. // ctx.setFontSize(30)
  349. // ctx.setFillStyle('#fff');
  350. // ctx.setTextAlign('left');
  351. // ctx.fillText('商城', 43, 878);
  352. // ctx.save();
  353. // ctx.setFontSize(36)
  354. // ctx.setFillStyle('#000');
  355. // ctx.fillText(siteName, 140, 880);
  356. // ctx.save();
  357. // const CONTENT_ROW_LENGTH = 36;
  358. const CONTENT_ROW_LENGTH = 35;
  359. let [contentLeng, contentArray, contentRows] = that.textByteLength(store_name,
  360. CONTENT_ROW_LENGTH);
  361. if (contentRows > 2) {
  362. contentRows = 2;
  363. let textArray = contentArray.slice(0, 2);
  364. textArray[textArray.length - 1] += '...';
  365. contentArray = textArray;
  366. }
  367. ctx.setTextAlign('left');
  368. ctx.setFontSize(38);
  369. ctx.setFillStyle('#000');
  370. let contentHh = 38;
  371. for (let m = 0; m < contentArray.length; m++) {
  372. if (m) {
  373. ctx.fillText(contentArray[m], 30, 900 + contentHh * m + 18);
  374. } else {
  375. ctx.fillText(contentArray[m], 30, 900 + contentHh * m);
  376. }
  377. }
  378. ctx.save();
  379. ctx.setTextAlign('left')
  380. ctx.setFontSize(32);
  381. ctx.setFillStyle('#999');
  382. ctx.fillText('¥' + ot_price, 30, 1148 + contentHh);
  383. var underline = function(ctx, text, x, y, size, color, thickness, offset) {
  384. var width = ctx.measureText(text).width;
  385. switch (ctx.textAlign) {
  386. case "center":
  387. x -= (width / 2);
  388. break;
  389. case "right":
  390. x -= width;
  391. break;
  392. }
  393. y += size + offset;
  394. ctx.beginPath();
  395. ctx.strokeStyle = color;
  396. ctx.lineWidth = thickness;
  397. ctx.moveTo(x, y);
  398. ctx.lineTo(x + width, y);
  399. ctx.stroke();
  400. }
  401. underline(ctx, '¥' + ot_price, 30, 1146, 28, '#999', 2, 0);
  402. ctx.save();
  403. ctx.setTextAlign('left')
  404. ctx.setFontSize(54);
  405. ctx.setFillStyle(fontColor);
  406. ctx.fillText('¥' + price, 20, 1070 + contentHh);
  407. ctx.save();
  408. ctx.setFillStyle('#F5F5F5');
  409. ctx.fillRect(0, 1222, WIDTH, 84);
  410. ctx.setFontSize(28);
  411. ctx.setFillStyle('#999');
  412. ctx.setTextAlign('center');
  413. ctx.fillText('长按识别图中的二维码查看商品详情', WIDTH / 2, 1272);
  414. ctx.save();
  415. let r = 93;
  416. let d = r * 2;
  417. let cx = WIDTH - d - 30;
  418. // let cy = 1112;
  419. let cy = 1000;
  420. ctx.arc(cx + r, cy + r, r, 0, 2 * Math.PI);
  421. ctx.drawImage(arr2[2], cx, cy, d, d);
  422. ctx.restore();
  423. // ctx.setTextAlign('left')
  424. // ctx.setFontSize(28);
  425. // ctx.setFillStyle('#999');
  426. // ctx.fillText('长按或扫描查看', 490, 1030 + contentHh);
  427. ctx.draw(true, function() {
  428. uni.canvasToTempFilePath({
  429. canvasId: 'myCanvas',
  430. fileType: 'png',
  431. // destWidth: WIDTH,
  432. // destHeight: HEIGHT,
  433. success: function(res) {
  434. // uni.hideLoading();
  435. successFn && successFn(res.tempFilePath);
  436. }
  437. })
  438. });
  439. },
  440. fail: function(err) {
  441. // uni.hideLoading();
  442. that.Tips({
  443. title: '无法获取图片信息'
  444. });
  445. }
  446. })
  447. },
  448. /**
  449. * 获取砍价/拼团海报
  450. * @param array arr2 海报素材 背景图
  451. * @param string store_name 素材文字
  452. * @param string price 价格
  453. * @param string ot_price 原始价格
  454. * @param function successFn 回调函数
  455. *
  456. *
  457. */
  458. bargainPosterCanvas: function(arr2, title, label, msg, price, wd, hg, successFn) {
  459. let that = this;
  460. const ctx = uni.createCanvasContext('myCanvas');
  461. ctx.clearRect(0, 0, 0, 0);
  462. /**
  463. * 只能获取合法域名下的图片信息,本地调试无法获取
  464. *
  465. */
  466. ctx.fillStyle = '#fff';
  467. ctx.fillRect(0, 0, wd * 2, hg * 2);
  468. uni.getImageInfo({
  469. src: arr2[0],
  470. success: function(res) {
  471. const WIDTH = res.width;
  472. const HEIGHT = res.height;
  473. ctx.drawImage(arr2[0], 0, 0, wd, hg);
  474. // 保证在不同机型对应坐标准确
  475. let labelx = 0.6500 //标签x
  476. let labely = 0.166 //标签y
  477. let pricex = 0.1857 //价格x
  478. let pricey = 0.180 //价格x
  479. let codex = 0.385 //二维码
  480. let codey = 0.77
  481. let picturex = 0.1571 //商品图左上点
  482. let picturey = 0.2916
  483. let picturebx = 0.6857 //商品图右下点
  484. let pictureby = 0.3916
  485. let msgx = 0.1036 //msg
  486. let msgy = 0.2306
  487. let codew = 0.25
  488. ctx.drawImage(arr2[1], wd * picturex, hg * picturey, wd * picturebx, hg * pictureby);
  489. ctx.drawImage(arr2[2], wd * codex, hg * codey, wd * codew, wd * codew);
  490. ctx.save();
  491. //标题
  492. const CONTENT_ROW_LENGTH = 28;
  493. let [contentLeng, contentArray, contentRows] = that.textByteLength(title,
  494. CONTENT_ROW_LENGTH);
  495. if (contentRows > 2) {
  496. contentRows = 2;
  497. let textArray = contentArray.slice(0, 2);
  498. textArray[textArray.length - 1] += '…';
  499. contentArray = textArray;
  500. }
  501. ctx.setTextAlign('left');
  502. ctx.setFillStyle('#000');
  503. if (contentArray.length < 2) {
  504. ctx.setFontSize(20);
  505. } else {
  506. ctx.setFontSize(20);
  507. }
  508. let contentHh = 8;
  509. for (let m = 0; m < contentArray.length; m++) {
  510. if (m) {
  511. ctx.fillText(contentArray[m], wd * msgx, 35 + contentHh * m + 18, 1100);
  512. } else {
  513. ctx.fillText(contentArray[m], wd * msgx, 35, 1100);
  514. }
  515. }
  516. // 标签内容
  517. ctx.setTextAlign('left')
  518. ctx.setFontSize(16);
  519. ctx.setFillStyle('#FFF');
  520. ctx.fillText(label, wd * labelx, hg * labely);
  521. ctx.save();
  522. // 价格
  523. ctx.setFillStyle('red');
  524. ctx.setFontSize(26);
  525. ctx.fillText(price, wd * pricex, hg * pricey);
  526. ctx.save();
  527. // msg
  528. ctx.setFillStyle('#333');
  529. ctx.setFontSize(16);
  530. ctx.fillText(msg, wd * msgx, hg * msgy);
  531. ctx.save();
  532. ctx.draw(true, () => {
  533. uni.canvasToTempFilePath({
  534. canvasId: 'myCanvas',
  535. fileType: 'png',
  536. quality: 1,
  537. success: (res) => {
  538. successFn && successFn(res.tempFilePath);
  539. uni.hideLoading();
  540. }
  541. })
  542. });
  543. },
  544. fail: function(err) {
  545. uni.hideLoading();
  546. that.Tips({
  547. title: '无法获取图片信息'
  548. });
  549. }
  550. })
  551. },
  552. /**
  553. * 图片圆角设置
  554. * @param string x x轴位置
  555. * @param string y y轴位置
  556. * @param string w 图片宽
  557. * @param string y 图片高
  558. * @param string r 圆角值
  559. */
  560. handleBorderRect(ctx, x, y, w, h, r) {
  561. ctx.beginPath();
  562. // 左上角
  563. ctx.arc(x + r, y + r, r, Math.PI, 1.5 * Math.PI);
  564. ctx.moveTo(x + r, y);
  565. ctx.lineTo(x + w - r, y);
  566. ctx.lineTo(x + w, y + r);
  567. // 右上角
  568. ctx.arc(x + w - r, y + r, r, 1.5 * Math.PI, 2 * Math.PI);
  569. ctx.lineTo(x + w, y + h - r);
  570. ctx.lineTo(x + w - r, y + h);
  571. // 右下角
  572. ctx.arc(x + w - r, y + h - r, r, 0, 0.5 * Math.PI);
  573. ctx.lineTo(x + r, y + h);
  574. ctx.lineTo(x, y + h - r);
  575. // 左下角
  576. ctx.arc(x + r, y + h - r, r, 0.5 * Math.PI, Math.PI);
  577. ctx.lineTo(x, y + r);
  578. ctx.lineTo(x + r, y);
  579. ctx.fill();
  580. ctx.closePath();
  581. },
  582. /**
  583. * 用户信息分享海报
  584. * @param array arr2 海报素材 1背景 0二维码
  585. * @param string nickname 昵称
  586. * @param string sitename 价格
  587. * @param function successFn 回调函数
  588. *
  589. *
  590. */
  591. userPosterCanvas: function(arr2, nickname, sitename, index, w, h, successFn) {
  592. let that = this;
  593. // uni.showLoading({
  594. // title: '海报生成中',
  595. // mask: true
  596. // });
  597. const ctx = uni.createCanvasContext('myCanvas' + index);
  598. ctx.clearRect(0, 0, 0, 0);
  599. /**
  600. * 只能获取合法域名下的图片信息,本地调试无法获取
  601. *
  602. */
  603. uni.getImageInfo({
  604. src: arr2[1],
  605. success: function(res) {
  606. // const WIDTH = res.width;
  607. // const HEIGHT = res.height;
  608. ctx.fillStyle = '#fff';
  609. ctx.fillRect(0, 0, w, h);
  610. ctx.drawImage(arr2[1], 0, 0, w, h);
  611. ctx.save();
  612. ctx.drawImage(arr2[0], w - 86, 386, 70, 70);
  613. ctx.save();
  614. ctx.setFontSize(16);
  615. ctx.setFillStyle('#333');
  616. ctx.fillText(nickname, 45, 414);
  617. ctx.save();
  618. const CONTENT_ROW_LENGTH = 25;
  619. const store_name = '邀请您加入' + sitename;
  620. let [contentLeng, contentArray, contentRows] = that.textByteLength(store_name,
  621. CONTENT_ROW_LENGTH);
  622. if (contentRows > 2) {
  623. contentRows = 2;
  624. let textArray = contentArray.slice(0, 2);
  625. textArray[textArray.length - 1] += '...';
  626. contentArray = textArray;
  627. }
  628. ctx.setTextAlign('left');
  629. ctx.setFillStyle('#999999');
  630. ctx.setFontSize(12);
  631. let contentHh = 38;
  632. for (let m = 0; m < contentArray.length; m++) {
  633. if (m) {
  634. ctx.fillText(contentArray[m], 16, 456);
  635. } else {
  636. ctx.fillText(contentArray[m], 16, 440);
  637. }
  638. }
  639. ctx.save();
  640. that.handleBorderRect(ctx, 16, 396, 24, 24, 12)
  641. ctx.clip();
  642. ctx.drawImage(arr2[2], 16, 396, 24, 24);
  643. ctx.draw(true, function() {
  644. uni.canvasToTempFilePath({
  645. canvasId: 'myCanvas' + index,
  646. fileType: 'png',
  647. quality: 1,
  648. success: function(res) {
  649. uni.hideLoading();
  650. successFn && successFn(res.tempFilePath);
  651. }
  652. })
  653. });
  654. },
  655. fail: function(err) {
  656. uni.hideLoading();
  657. that.Tips({
  658. title: ''
  659. });
  660. }
  661. })
  662. },
  663. // uniapp 判断 IOS和Android的GPS是否开启
  664. checkOpenGPSServiceByAndroidIOS() {
  665. let system = uni.getSystemInfoSync(); // 获取系统信息
  666. console.log('yyy', system);
  667. if (system.platform === 'android') { // 判断平台
  668. var context = plus.android.importClass("android.content.Context");
  669. var locationManager = plus.android.importClass("android.location.LocationManager");
  670. var main = plus.android.runtimeMainActivity();
  671. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  672. if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
  673. return false
  674. } else {
  675. return true
  676. }
  677. } else if (system.platform === 'ios' || 'devtools') {
  678. var cllocationManger = plus.ios.import("CLLocationManager");
  679. var enable = cllocationManger.locationServicesEnabled();
  680. var status = cllocationManger.authorizationStatus();
  681. plus.ios.deleteObject(cllocationManger);
  682. if (enable && status != 2) {
  683. return true
  684. console.log("手机系统的定位已经打开");
  685. } else {
  686. return false
  687. console.log("手机系统的定位没有打开");
  688. }
  689. }
  690. },
  691. /*
  692. * 单图上传
  693. * @param object opt
  694. * @param callable successCallback 成功执行方法 data
  695. * @param callable errorCallback 失败执行方法
  696. */
  697. uploadImageOne: function(opt, successCallback, errorCallback) {
  698. let that = this;
  699. // #ifdef APP
  700. let boolad = uni.getStorageSync("boolLoad") || false
  701. // if (permision.isIOS) {
  702. if (boolad) {
  703. upimg()
  704. } else {
  705. let title = '申请相册权限';
  706. let content = "是否允许访问相册用于上传图片?"
  707. uni.showModal({
  708. title,
  709. content,
  710. cancelText: '拒绝',
  711. confirmText: '允许',
  712. success: res => {
  713. if (res.confirm) {
  714. uni.setStorageSync("boolLoad", true)
  715. upimg()
  716. }
  717. },
  718. });
  719. }
  720. // #endif
  721. // #ifndef APP
  722. upimg()
  723. // #endif
  724. function upimg() {
  725. if (typeof opt === 'string') {
  726. let url = opt;
  727. opt = {};
  728. opt.url = url;
  729. }
  730. let count = opt.count || 1,
  731. sizeType = opt.sizeType || ['compressed'],
  732. sourceType = opt.sourceType || ['album', 'camera'],
  733. is_load = opt.is_load || true,
  734. uploadUrl = opt.url || '',
  735. inputName = opt.name || 'pics',
  736. fileType = opt.fileType || 'image';
  737. uni.chooseImage({
  738. count: count, //最多可以选择的图片总数
  739. sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
  740. sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
  741. success: function(res) {
  742. //启动上传等待中...
  743. uni.showLoading({
  744. title: '图片上传中',
  745. });
  746. uni.uploadFile({
  747. url: HTTP_REQUEST_URL + '/api/' + uploadUrl,
  748. filePath: res.tempFilePaths[0],
  749. fileType: fileType,
  750. name: inputName,
  751. formData: {
  752. 'filename': inputName
  753. },
  754. header: {
  755. // #ifdef MP
  756. "Content-Type": "multipart/form-data",
  757. // #endif
  758. [TOKENNAME]: 'Bearer ' + store.state.app.token
  759. },
  760. success: function(res) {
  761. uni.hideLoading();
  762. if (res.statusCode == 403) {
  763. that.Tips({
  764. title: res.data
  765. });
  766. } else if (res.statusCode == 413) {
  767. that.Tips({
  768. title: '上传图片失败,请重新上传小尺寸图片'
  769. });
  770. } else {
  771. let data = res.data ? JSON.parse(res.data) : {};
  772. if (data.status == 200) {
  773. successCallback && successCallback(data)
  774. } else {
  775. errorCallback && errorCallback(data);
  776. that.Tips({
  777. title: data.msg
  778. });
  779. }
  780. }
  781. },
  782. fail: function(res) {
  783. uni.hideLoading();
  784. that.Tips({
  785. title: '上传图片失败'
  786. });
  787. }
  788. })
  789. }
  790. })
  791. }
  792. },
  793. /*
  794. * 单图上传压缩版
  795. * @param object opt
  796. * @param callable successCallback 成功执行方法 data
  797. * @param callable errorCallback 失败执行方法
  798. */
  799. uploadImageChange: function(opt, successCallback, errorCallback, sizeCallback) {
  800. let that = this;
  801. // #ifdef APP
  802. let boolad = uni.getStorageSync("boolLoad") || false
  803. // if (permision.isIOS) {
  804. if (boolad || plus.os.name == "iOS") {
  805. upimg()
  806. } else {
  807. let title = '申请相册权限';
  808. let content = "是否允许访问相册用于上传图片?"
  809. uni.showModal({
  810. title,
  811. content,
  812. cancelText: '拒绝',
  813. confirmText: '允许',
  814. success: res => {
  815. if (res.confirm) {
  816. uni.setStorageSync("boolLoad", true)
  817. upimg()
  818. }
  819. },
  820. });
  821. }
  822. // #endif
  823. // #ifndef APP
  824. upimg()
  825. // #endif
  826. function upimg() {
  827. if (typeof opt === 'string') {
  828. let url = opt;
  829. opt = {};
  830. opt.url = url;
  831. }
  832. let count = opt.count || 1,
  833. sizeType = opt.sizeType || ['compressed'],
  834. sourceType = opt.sourceType || ['album', 'camera'],
  835. is_load = opt.is_load || true,
  836. uploadUrl = opt.url || '',
  837. inputName = opt.name || 'pics',
  838. fileType = opt.fileType || 'image';
  839. uni.chooseImage({
  840. count: count, //最多可以选择的图片总数
  841. sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
  842. sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
  843. success: function(res) {
  844. //启动上传等待中...
  845. let imgSrc
  846. let objImg = res.tempFilePaths;
  847. objImg.forEach(item => {
  848. uni.getImageInfo({
  849. src: item,
  850. success(ress) {
  851. uni.showLoading({
  852. title: '图片上传中',
  853. });
  854. if (res.tempFiles[0].size <= 2097152) {
  855. uploadImg(ress.path)
  856. return
  857. }
  858. // uploadImg(canvasPath.tempFilePath)
  859. let canvasWidth, canvasHeight, xs, maxWidth = 750
  860. xs = ress.width / ress.height // 宽高比例
  861. if (ress.width > maxWidth) {
  862. canvasWidth = maxWidth // 这里是最大限制宽度
  863. canvasHeight = maxWidth / xs
  864. } else {
  865. canvasWidth = ress.width
  866. canvasHeight = ress.height
  867. }
  868. sizeCallback && sizeCallback({
  869. w: canvasWidth,
  870. h: canvasHeight
  871. })
  872. let canvas = uni.createCanvasContext('canvas');
  873. canvas.width = canvasWidth
  874. canvas.height = canvasHeight
  875. canvas.clearRect(0, 0, canvasWidth, canvasHeight);
  876. canvas.drawImage(ress.path, 0, 0, canvasWidth,
  877. canvasHeight)
  878. canvas.save();
  879. // 这里的画布drawImage是一种异步属性 可能存在未绘制全就执行了draw的问题 so添加延迟
  880. setTimeout(e => {
  881. canvas.draw(true, () => {
  882. uni.canvasToTempFilePath({
  883. canvasId: 'canvas',
  884. fileType: 'JPEG',
  885. destWidth: canvasWidth,
  886. destHeight: canvasHeight,
  887. quality: 0.7,
  888. success: function(
  889. canvasPath
  890. ) {
  891. uploadImg(
  892. canvasPath
  893. .tempFilePath
  894. )
  895. }
  896. })
  897. });
  898. }, 200)
  899. }
  900. })
  901. })
  902. }
  903. })
  904. }
  905. function uploadImg(filePath) {
  906. uni.uploadFile({
  907. url: HTTP_REQUEST_URL + '/api/' + uploadUrl,
  908. filePath,
  909. fileType: fileType,
  910. name: inputName,
  911. formData: {
  912. 'filename': inputName
  913. },
  914. header: {
  915. // #ifdef MP
  916. "Content-Type": "multipart/form-data",
  917. // #endif
  918. [TOKENNAME]: 'Bearer ' + store.state.app.token
  919. },
  920. success: function(res) {
  921. uni.hideLoading();
  922. if (res.statusCode == 403) {
  923. that.Tips({
  924. title: res.data
  925. });
  926. } else {
  927. let data = res.data ? JSON.parse(res.data) : {};
  928. if (data.status == 200) {
  929. successCallback && successCallback(data)
  930. } else {
  931. errorCallback && errorCallback(data);
  932. that.Tips({
  933. title: data.msg
  934. });
  935. }
  936. }
  937. },
  938. fail: function(res) {
  939. uni.hideLoading();
  940. that.Tips({
  941. title: '上传图片失败'
  942. });
  943. }
  944. })
  945. }
  946. },
  947. /**
  948. * 处理客服不同的跳转;
  949. *
  950. */
  951. getCustomer(userInfo, url, storeInfo, show) {
  952. let self = this;
  953. customerType().then(res => {
  954. let data = res.data;
  955. if (data.customer_type == 1) {
  956. uni.makePhoneCall({
  957. phoneNumber: data.customer_phone
  958. });
  959. } else if (data.customer_type == 2) {
  960. let href = data.customer_url;
  961. let hrefO = href + '?uid=' + userInfo.uid + '&nickName=' + userInfo.nickname + '&phone=' +
  962. userInfo.phone + '&sex=' + userInfo.sex + '&avatar=' + userInfo.avatar +
  963. '&openid=' + userInfo.openid;
  964. let hrefT = href + '&uid=' + userInfo.uid + '&nickName=' + userInfo.nickname + '&phone=' +
  965. userInfo.phone + '&sex=' + userInfo.sex + '&avatar=' + userInfo.avatar +
  966. '&openid=' + userInfo.openid;
  967. let urls = encodeURIComponent(href.indexOf('?') === -1 ? hrefO : hrefT);
  968. if (data.customer_url.indexOf('work.weixin.qq.com') > 0) {
  969. // #ifdef MP
  970. wx.openCustomerServiceChat({
  971. extInfo: {
  972. url: data.customer_url
  973. },
  974. corpId: data.wechat_work_corpid,
  975. showMessageCard: show ? true : false,
  976. sendMessageTitle: show ? storeInfo.store_name : '',
  977. sendMessagePath: show ? storeInfo.path : '',
  978. sendMessageImg: show ? storeInfo.image : '',
  979. success(res) {},
  980. fail(err) {
  981. self.Tips({
  982. title: err.errMsg
  983. });
  984. }
  985. })
  986. // #endif
  987. // #ifdef H5
  988. return window.location.href = data.customer_url
  989. // #endif
  990. // #ifdef APP-PLUS
  991. plus.runtime.openURL(data.customer_url)
  992. // #endif
  993. } else {
  994. uni.navigateTo({
  995. url: `/pages/annex/web_view/index?url=${urls}`
  996. });
  997. }
  998. } else {
  999. uni.navigateTo({
  1000. url: url || '/pages/extension/customer_list/chat'
  1001. })
  1002. }
  1003. }).catch(err => {
  1004. self.Tips({
  1005. title: err
  1006. });
  1007. })
  1008. },
  1009. /**
  1010. * 小程序头像获取上传
  1011. * @param uploadUrl 上传接口地址
  1012. * @param filePath 上传文件路径
  1013. * @param successCallback success回调
  1014. * @param errorCallback err回调
  1015. */
  1016. uploadImgs(uploadUrl, filePath, successCallback, errorCallback) {
  1017. let that = this;
  1018. uni.uploadFile({
  1019. url: HTTP_REQUEST_URL + '/api/' + uploadUrl,
  1020. filePath: filePath,
  1021. fileType: 'image',
  1022. name: 'pics',
  1023. formData: {
  1024. 'filename': 'pics'
  1025. },
  1026. header: {
  1027. // #ifdef MP
  1028. "Content-Type": "multipart/form-data",
  1029. // #endif
  1030. [TOKENNAME]: 'Bearer ' + store.state.app.token
  1031. },
  1032. success: (res) => {
  1033. uni.hideLoading();
  1034. if (res.statusCode == 403) {
  1035. that.Tips({
  1036. title: res.data
  1037. });
  1038. } else if (res.statusCode == 413) {
  1039. that.Tips({
  1040. title: '上传图片失败,请重新上传小尺寸图片'
  1041. });
  1042. } else {
  1043. let data = res.data ? JSON.parse(res.data) : {};
  1044. if (data.status == 200) {
  1045. successCallback && successCallback(data)
  1046. } else {
  1047. errorCallback && errorCallback(data);
  1048. that.Tips({
  1049. title: data.msg
  1050. });
  1051. }
  1052. }
  1053. },
  1054. fail: (err) => {
  1055. uni.hideLoading();
  1056. that.Tips({
  1057. title: '上传图片失败'
  1058. });
  1059. }
  1060. })
  1061. },
  1062. /**
  1063. * 小程序比较版本信息
  1064. * @param v1 当前版本
  1065. * @param v2 进行比较的版本
  1066. * @return boolen
  1067. *
  1068. */
  1069. compareVersion(v1, v2) {
  1070. v1 = v1.split('.')
  1071. v2 = v2.split('.')
  1072. const len = Math.max(v1.length, v2.length)
  1073. while (v1.length < len) {
  1074. v1.push('0')
  1075. }
  1076. while (v2.length < len) {
  1077. v2.push('0')
  1078. }
  1079. for (let i = 0; i < len; i++) {
  1080. const num1 = parseInt(v1[i])
  1081. const num2 = parseInt(v2[i])
  1082. if (num1 > num2) {
  1083. return 1
  1084. } else if (num1 < num2) {
  1085. return -1
  1086. }
  1087. }
  1088. return 0
  1089. },
  1090. /**
  1091. * 处理服务器扫码带进来的参数
  1092. * @param string param 扫码携带参数
  1093. * @param string k 整体分割符 默认为:&
  1094. * @param string p 单个分隔符 默认为:=
  1095. * @return object
  1096. *
  1097. */
  1098. // #ifdef MP
  1099. getUrlParams: function(param, k, p) {
  1100. if (typeof param != 'string') return {};
  1101. k = k ? k : '&'; //整体参数分隔符
  1102. p = p ? p : '='; //单个参数分隔符
  1103. var value = {};
  1104. if (param.indexOf(k) !== -1) {
  1105. param = param.split(k);
  1106. for (var val in param) {
  1107. if (param[val].indexOf(p) !== -1) {
  1108. var item = param[val].split(p);
  1109. value[item[0]] = item[1];
  1110. }
  1111. }
  1112. } else if (param.indexOf(p) !== -1) {
  1113. var item = param.split(p);
  1114. value[item[0]] = item[1];
  1115. } else {
  1116. return param;
  1117. }
  1118. return value;
  1119. },
  1120. // #endif
  1121. /*
  1122. * 合并数组
  1123. */
  1124. SplitArray(list, sp) {
  1125. if (typeof list != 'object') return [];
  1126. if (sp === undefined) sp = [];
  1127. for (var i = 0; i < list.length; i++) {
  1128. sp.push(list[i]);
  1129. }
  1130. return sp;
  1131. },
  1132. trim(backUrlCRshlcICwGdGY) {
  1133. return String.prototype.trim.call(backUrlCRshlcICwGdGY);
  1134. },
  1135. $h: {
  1136. //除法函数,用来得到精确的除法结果
  1137. //说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
  1138. //调用:$h.Div(arg1,arg2)
  1139. //返回值:arg1除以arg2的精确结果
  1140. Div: function(arg1, arg2) {
  1141. arg1 = parseFloat(arg1);
  1142. arg2 = parseFloat(arg2);
  1143. var t1 = 0,
  1144. t2 = 0,
  1145. r1, r2;
  1146. try {
  1147. t1 = arg1.toString().split(".")[1].length;
  1148. } catch (e) {}
  1149. try {
  1150. t2 = arg2.toString().split(".")[1].length;
  1151. } catch (e) {}
  1152. r1 = Number(arg1.toString().replace(".", ""));
  1153. r2 = Number(arg2.toString().replace(".", ""));
  1154. return this.Mul(r1 / r2, Math.pow(10, t2 - t1));
  1155. },
  1156. //加法函数,用来得到精确的加法结果
  1157. //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
  1158. //调用:$h.Add(arg1,arg2)
  1159. //返回值:arg1加上arg2的精确结果
  1160. Add: function(arg1, arg2) {
  1161. arg2 = parseFloat(arg2);
  1162. var r1, r2, m;
  1163. try {
  1164. r1 = arg1.toString().split(".")[1].length
  1165. } catch (e) {
  1166. r1 = 0
  1167. }
  1168. try {
  1169. r2 = arg2.toString().split(".")[1].length
  1170. } catch (e) {
  1171. r2 = 0
  1172. }
  1173. m = Math.pow(100, Math.max(r1, r2));
  1174. return (this.Mul(arg1, m) + this.Mul(arg2, m)) / m;
  1175. },
  1176. //减法函数,用来得到精确的减法结果
  1177. //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的减法结果。
  1178. //调用:$h.Sub(arg1,arg2)
  1179. //返回值:arg1减去arg2的精确结果
  1180. Sub: function(arg1, arg2) {
  1181. arg1 = parseFloat(arg1);
  1182. arg2 = parseFloat(arg2);
  1183. var r1, r2, m, n;
  1184. try {
  1185. r1 = arg1.toString().split(".")[1].length
  1186. } catch (e) {
  1187. r1 = 0
  1188. }
  1189. try {
  1190. r2 = arg2.toString().split(".")[1].length
  1191. } catch (e) {
  1192. r2 = 0
  1193. }
  1194. m = Math.pow(10, Math.max(r1, r2));
  1195. //动态控制精度长度
  1196. n = (r1 >= r2) ? r1 : r2;
  1197. return ((this.Mul(arg1, m) - this.Mul(arg2, m)) / m).toFixed(n);
  1198. },
  1199. //乘法函数,用来得到精确的乘法结果
  1200. //说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
  1201. //调用:$h.Mul(arg1,arg2)
  1202. //返回值:arg1乘以arg2的精确结果
  1203. Mul: function(arg1, arg2) {
  1204. arg1 = parseFloat(arg1);
  1205. arg2 = parseFloat(arg2);
  1206. var m = 0,
  1207. s1 = arg1.toString(),
  1208. s2 = arg2.toString();
  1209. try {
  1210. m += s1.split(".")[1].length
  1211. } catch (e) {}
  1212. try {
  1213. m += s2.split(".")[1].length
  1214. } catch (e) {}
  1215. return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
  1216. },
  1217. },
  1218. // 获取地理位置;
  1219. $L: {
  1220. async getLocation() {
  1221. // #ifdef APP-PLUS
  1222. let status = await this.checkPermission();
  1223. if (status !== 1) {
  1224. return;
  1225. }
  1226. // #endif
  1227. // #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
  1228. let status = await this.getSetting();
  1229. if (status === 2) {
  1230. this.openSetting();
  1231. return;
  1232. }
  1233. // #endif
  1234. this.doGetLocation();
  1235. },
  1236. doGetLocation() {
  1237. uni.getLocation({
  1238. success: (res) => {
  1239. uni.removeStorageSync('CACHE_LONGITUDE');
  1240. uni.removeStorageSync('CACHE_LATITUDE');
  1241. uni.setStorageSync('CACHE_LONGITUDE', res.longitude);
  1242. uni.setStorageSync('CACHE_LATITUDE', res.latitude);
  1243. },
  1244. fail: (err) => {
  1245. // #ifdef MP-BAIDU
  1246. if (err.errCode === 202 || err.errCode === 10003) { // 202模拟器 10003真机 user deny
  1247. this.openSetting();
  1248. }
  1249. // #endif
  1250. // #ifndef MP-BAIDU
  1251. if (err.errMsg.indexOf("auth deny") >= 0) {
  1252. uni.showToast({
  1253. title: "访问位置被拒绝"
  1254. })
  1255. } else {
  1256. uni.showToast({
  1257. title: err.errMsg
  1258. })
  1259. }
  1260. // #endif
  1261. }
  1262. })
  1263. },
  1264. getSetting: function() {
  1265. return new Promise((resolve, reject) => {
  1266. uni.getSetting({
  1267. success: (res) => {
  1268. if (res.authSetting['scope.userLocation'] === undefined) {
  1269. resolve(0);
  1270. return;
  1271. }
  1272. if (res.authSetting['scope.userLocation']) {
  1273. resolve(1);
  1274. } else {
  1275. resolve(2);
  1276. }
  1277. }
  1278. });
  1279. });
  1280. },
  1281. openSetting: function() {
  1282. uni.openSetting({
  1283. success: (res) => {
  1284. if (res.authSetting && res.authSetting['scope.userLocation']) {
  1285. this.doGetLocation();
  1286. }
  1287. },
  1288. fail: (err) => {}
  1289. })
  1290. },
  1291. async checkPermission() {
  1292. let status = permision.isIOS ? await permision.requestIOS('location') :
  1293. await permision.requestAndroid('android.permission.ACCESS_FINE_LOCATION');
  1294. if (status === null || status === 1) {
  1295. status = 1;
  1296. } else if (status === 2) {
  1297. uni.showModal({
  1298. content: "系统定位已关闭",
  1299. confirmText: "确定",
  1300. showCancel: false,
  1301. success: function(res) {}
  1302. })
  1303. } else if (status.code) {
  1304. uni.showModal({
  1305. content: status.message
  1306. })
  1307. } else {
  1308. uni.showModal({
  1309. content: "需要定位权限",
  1310. confirmText: "设置",
  1311. success: function(res) {
  1312. if (res.confirm) {
  1313. permision.gotoAppSetting();
  1314. }
  1315. }
  1316. })
  1317. }
  1318. return status;
  1319. },
  1320. }
  1321. }