request.js 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504
  1. const app = getApp();
  2. let WebIM = (wx.WebIM = require("../hxChatSDK/utils/WebIM")["default"]);
  3. import JSEncrypt from '../utils/jsencrypt.js'
  4. const env = {
  5. NODE_ENV: 'prd',
  6. dev: {
  7. // apiUrl: 'https://rsapi.zhiqiyun.net'
  8. apiUrl: 'https://unwx.e-chinalife.com/hkttest',
  9. },
  10. prd: {
  11. apiUrl: 'https://unwx.e-chinalife.com/hktonline'
  12. },
  13. pota: {
  14. // apiUrl: 'http://192.168.110.98:8098'
  15. // apiUrl: 'http://192.168.110.180:8098' ,//f
  16. // apiUrl: 'http://192.168.110.182:8094' ,//z
  17. // apiUrl: 'http://192.168.110.176:8098' //y
  18. // apiUrl: 'http://192.168.110.117:8098'//l
  19. // apiUrl: 'http://192.168.110.216:8098'
  20. apiUrl: 'http://192.168.110.180:8098' ,//wjg
  21. }
  22. }
  23. var header = {
  24. 'content-type': 'application/x-www-form-urlencoded',
  25. }
  26. /**小程序配置 */
  27. const publics = {
  28. picUrls: 'https://zhiqiyun.oss-cn-hangzhou.aliyuncs.com/static/', //图片地址
  29. 'copyrighttitle': '智企云', //底部版权公司名称
  30. 'copyrighttel': '400-698-5980', //底部版权服务电话
  31. 'copyrightlogo': 'zhiqiyun', //底部版权 logo 文件名
  32. // 'mapLBSKEY': 'CBRBZ-5SHKL-3NCPX-EP5MQ-B57M6-CWFUU',
  33. 'mapLBSKEY': 'KBIBZ-RUCK4-FO4UT-FFSHH-V52WQ-LGF62',
  34. 'iconSrc': 'red/',
  35. 'titleTopBgColor': '#FFF',
  36. // 小程序ID wxe7bec198ecfe1162
  37. // 文章栏目code
  38. 'fxCode': 'faxian', //发现
  39. 'xbrmCode': 'xiaobairumen', //小白入门
  40. 'tbalCode': 'toubaoanli', //投保案例
  41. 'lpalCode': 'lipeianli', //理赔案例
  42. 'gfdtCode':'gfdt',//官方动态
  43. // 加密
  44. 'RSAKEY':"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDehEEc+q5s+m8c7fajkuzh5Cj/obdzngBZZmOHUcc3ck3oSfQQgs/bUoVCccJqbSSL4Z2+/BEq4wNeSeIH4nb26Euml2HhtFzVHej+of2r6NR+zB2DVbddoHJxcvb3kTC5KWPEZ6pN9aw4guMk2d78ZhWdfYSkmuNAebytSyc7ZQIDAQAB"
  45. }
  46. /*
  47. * 获取token
  48. */
  49. const getToken = (success) => {
  50. let token = getStorage('AUTH_TOKEN');
  51. if (token) {
  52. success.call(this, token);
  53. return false;
  54. } else {
  55. loadToken(data => {
  56. success.call(this, data);
  57. });
  58. }
  59. }
  60. const loadToken = (success) => {
  61. let that = this
  62. uni.request({
  63. url: env[env.NODE_ENV].apiUrl + '/api/access_token',
  64. data: {},
  65. method: 'get',
  66. header: header,
  67. success(json) {
  68. if (json.statusCode !== 200) return msg(json.data.message);
  69. if (json.data.code !== 0) return msg(json.data.msg)
  70. setStorage('AUTH_TOKEN', json.data.data);
  71. success.call(that, json.data.data);
  72. },
  73. fail() {
  74. msg('access_token 获取失败');
  75. }
  76. })
  77. }
  78. /**
  79. * 微信小程序静默授权登录
  80. * @param {*} parentId
  81. * @param {*} merchantId
  82. */
  83. const silenceLogin = (parentId, merchantId) => {
  84. // #ifdef MP-WEIXIN
  85. return new Promise((resolve, reject) => {
  86. if (!isLogins(false)) { //未登录
  87. uni.login({
  88. success(res) {
  89. console.log('静默授权登录>>>', res);
  90. let params = {
  91. code: res.code,
  92. parentId: parentId ? parentId : '',
  93. merchantId: merchantId ? merchantId : ''
  94. }
  95. postRequest('/api/v3/silence/login', params, data => {
  96. if (data.token) setStorage('AUTH_TOKEN', data.token);
  97. getRequest('/api/user/info', {}, suc => {
  98. data.isDistriUser = suc.isDistriUser;
  99. setStorage('userInfo', data);
  100. getIMToken(false);
  101. getIMChatMsg()
  102. });
  103. resolve();
  104. });
  105. }
  106. });
  107. } else {
  108. initIMChat();
  109. getIMChatMsg()
  110. resolve();
  111. }
  112. });
  113. // #endif
  114. }
  115. const getsysConfig = (upData)=>{
  116. // upData true刷新缓存系统参数
  117. return new Promise((r,j)=>{
  118. if(upData){
  119. getRequest('/api/other/config', {}, res => {
  120. setStorage('configRes', JSON.stringify(res));
  121. r(res)
  122. });
  123. }else{
  124. if(getStorage('configRes')) r(JSON.parse(getStorage('configRes')))
  125. else{
  126. getRequest('/api/other/config', {}, res => {
  127. setStorage('configRes', JSON.stringify(res));
  128. r(res)
  129. });
  130. }
  131. }
  132. })
  133. }
  134. /**
  135. * 初始化 IMsdk
  136. */
  137. const initIMChat = () => {
  138. var user = getStorage('userInfo');
  139. if (user) {
  140. var imToken = getStorage('imToken');
  141. if (imToken) {
  142. //初始化IM
  143. uni.setStorage({
  144. key: "myUsername",
  145. data: 'rs_' + user.id
  146. });
  147. getApp().globalData.conn.open({
  148. apiUrl: WebIM.config.apiURL,
  149. user: 'rs_' + user.id,
  150. pwd: getStorage('imToken'),
  151. accessToken: getStorage('imToken'),
  152. appKey: WebIM.config.appkey
  153. });
  154. } else {
  155. getRequest('/api/im/msg/userToken', {}, suc => {
  156. setStorage('imToken', suc);
  157. uni.setStorage({
  158. key: "myUsername",
  159. data: 'rs_' + user.id
  160. });
  161. getApp().globalData.conn.open({
  162. apiUrl: WebIM.config.apiURL,
  163. user: 'rs_' + user.id,
  164. pwd: getStorage('imToken'),
  165. accessToken: getStorage('imToken'),
  166. appKey: WebIM.config.appkey
  167. });
  168. });
  169. }
  170. }
  171. }
  172. const getIMToken = (isUpdatToken) => {
  173. var user = getStorage('userInfo');
  174. getRequest('/api/im/msg/userToken', {}, suc => {
  175. setStorage('imToken', suc);
  176. if (isUpdatToken) {
  177. //更新token
  178. uni.setStorage({
  179. key: "myUsername",
  180. data: 'rs_' + user.id
  181. });
  182. getApp().globalData.conn.open({
  183. user: 'rs_' + user.id,
  184. accessToken: getStorage('imToken'),
  185. });
  186. getApp().globalData.onLoginSuccess(uni.getStorageSync("myUsername"));
  187. } else {
  188. initIMChat();
  189. }
  190. }, true);
  191. }
  192. const getIMChatMsg = ()=>{
  193. uni.getStorageInfo({
  194. success: function(res) {
  195. let storageKeys = res.keys;
  196. let haveHistoryChatMsgKeys = false
  197. storageKeys.forEach((item) => {
  198. let key = item
  199. if(item==="myUsername"){
  200. uni.setStorageSync(item,uni.getStorageSync(item).replace('RS_','rs_'))
  201. }
  202. if(item.indexOf('imUserInfo')>-1){
  203. uni.setStorageSync(item.replaceAll('RS_','rs_'),uni.getStorageSync(item))
  204. if(item!==key){
  205. uni.removeStorageSync(key)
  206. }
  207. }
  208. if(item.indexOf('rendered')>-1){
  209. let key = item
  210. haveHistoryChatMsgKeys = true
  211. let rs = uni.getStorageSync(item)
  212. rs.map(item=>{
  213. item.info.from = item.info.from.replaceAll('RS_','rs_')
  214. item.info.to = item.info.to.replaceAll('RS_','rs_')
  215. item.username = item.username.replaceAll('RS_','rs_')
  216. item.yourname = item.yourname.replaceAll('RS_','rs_')
  217. })
  218. uni.setStorageSync(item.replaceAll('RS_','rs_'),rs)
  219. if(item!==key){
  220. uni.removeStorageSync(key)
  221. }
  222. }
  223. });
  224. if(haveHistoryChatMsgKeys){
  225. }else{
  226. getRequest('/api/im/msg/pageWechat', {}, suc => {
  227. if(suc.length>0){
  228. suc.map(item=>{
  229. console.log('skey:getRequest')
  230. let skey = ''
  231. if(item[0].info.from===('rs_'+getStorage('userInfo').id)){
  232. skey = "rendered_"+item[0].info.to + item[0].info.from
  233. }else{
  234. skey = "rendered_"+item[0].info.from + item[0].info.to
  235. }
  236. if(skey) {
  237. console.log('skey:',skey)
  238. console.log('skey item:',item)
  239. item.forEach(iitem=>{
  240. if(iitem.msg.type=='txt'){
  241. iitem.msg.data = WebIM.parseEmoji(iitem.msg.data.toString().replace(/\n/gm, ""));
  242. }
  243. })
  244. console.log('WebIM.parseEmoji',item)
  245. uni.setStorageSync(skey,item)
  246. }
  247. if(item[0].msg.extTo){
  248. console.log('item[0].msg.extTo',item[0].msg.extTo)
  249. let key = item
  250. uni.setStorageSync('imUserInfo_rs_'+item[0].msg.extTo.id,{
  251. nickName:item[0].msg.extTo.nickName,
  252. id:item[0].msg.extTo.id,
  253. avatar:item[0].msg.extTo.avatar
  254. })
  255. }
  256. if(item[0].msg.ext){
  257. console.log('item[0].msg.ext',item[0].msg.ext)
  258. let key = item
  259. uni.setStorageSync('imUserInfo_rs_'+item[0].msg.ext.id,{
  260. nickName:item[0].msg.ext.nickName,
  261. id:item[0].msg.ext.id,
  262. avatar:item[0].msg.ext.avatar
  263. })
  264. }
  265. uni.setStorageSync('imUserInfo_rs_'+getStorage('userInfo').id,{
  266. nickName:getStorage('userInfo').nickName,
  267. id:getStorage('userInfo').id,
  268. avatar:getStorage('userInfo').avatar
  269. })
  270. })
  271. }
  272. }, false);
  273. }
  274. },
  275. });
  276. }
  277. /**
  278. * 跳转进入消息列表
  279. */
  280. const jumpConversation = () => {
  281. if (!isLogins(true)) { //未登录
  282. return;
  283. }
  284. getIMToken(true);
  285. }
  286. const getWXUserProfile = (suc) => {
  287. let that = this;
  288. var sessionKey = '';
  289. var openid = '';
  290. getApp().globalData.getCheckSessoin(json => {
  291. sessionKey = json.session_key;
  292. openid = json.openid;
  293. });
  294. try {
  295. uni.getUserProfile({
  296. desc: '完善信息',
  297. success: res => {
  298. updataWxInfos(res.iv, res.encryptedData, sessionKey, openid, suc);
  299. },
  300. fail: res => {
  301. console.log('授权失败数据>>>', res);
  302. msg(res);
  303. }
  304. });
  305. } catch (e) {
  306. // 老版
  307. wx.getUserInfo({
  308. success: function(ress) {
  309. updataWxInfos(res.iv, res.encryptedData, sessionKey, openid, suc);
  310. }
  311. });
  312. }
  313. }
  314. /**
  315. * 保存微信头像
  316. */
  317. const updataWxInfos = (iv, encryptedData, sessionKey, openid, suc) => {
  318. if (!encryptedData || !iv) return false;
  319. let _params = {
  320. sessionKey: sessionKey,
  321. openId: openid,
  322. iv: iv,
  323. encryptedData: encryptedData
  324. };
  325. postRequest('/api/user/weixin/update', _params, json => {
  326. setStorage('userInfo', json);
  327. suc.call();
  328. });
  329. }
  330. const clearValueEmpty = (data) => {
  331. let keyValue = {};
  332. for (let key in data) {
  333. let value = typeof data[key];
  334. if (value == 'string' && value) {
  335. if (data[key] != 'undefined' && data[key] != " " && data[key] != undefined && data[key] != null) {
  336. keyValue[key] = data[key];
  337. }
  338. // keyValue[key] = data[key];
  339. } else if (value == 'number' && value != null) {
  340. keyValue[key] = data[key];
  341. } else if (value == 'boolean') {
  342. keyValue[key] = data[key];
  343. } else {
  344. if (data[key]) keyValue[key] = data[key];
  345. }
  346. }
  347. return keyValue;
  348. }
  349. /**
  350. * 公共请求
  351. *
  352. * @param {*} url 请求url
  353. * @param {*} data 请求参数
  354. * @param {*} method 请求方法
  355. * @param {*} success 成功函数
  356. * @param {*} isLoad 是否显示加载提示
  357. */
  358. const baseRequest = (url, data, method, success, isLoad) => {
  359. let postData = data
  360. getToken(token => {
  361. if (!isLoad) uni.showNavigationBarLoading();
  362. header.authorityToken = token;
  363. // if (url.indexOf('/v3') != -1 || url.indexOf('/paper/create') != -1) {
  364. // header['content-type'] = 'application/json;charset=UTF-8'
  365. // } else {
  366. header['content-type'] = 'application/json;charset=UTF-8'
  367. // }
  368. if(url=='/api/user/userInfoById'||url=='/api/visiting/card/info'||url=='/api/user/getUserInfoBySaleNo'){
  369. if(data.id){
  370. let encrypt = new JSEncrypt()
  371. encrypt.setPublicKey(publics.RSAKEY)
  372. data.id = encrypt.encrypt(data.id)
  373. }
  374. if(data.userId){
  375. let encrypt = new JSEncrypt()
  376. encrypt.setPublicKey(publics.RSAKEY)
  377. data.userId = encrypt.encrypt(data.userId)
  378. }
  379. }
  380. uni.request({
  381. url: env[env.NODE_ENV].apiUrl + url,
  382. data: clearValueEmpty(data),
  383. method: method,
  384. header: header,
  385. success(json) {
  386. if (!isLoad) uni.hideNavigationBarLoading();
  387. if (json.statusCode !== 200) return msg(json.data.message);
  388. if (json.data.code === 10021 || json.data.code === 10020) {
  389. // console.log("第二次执行")
  390. removeStorage('AUTH_TOKEN');
  391. removeStorage('userInfo');
  392. return redirectIndex();
  393. }
  394. if (json.data.code !== 0) {
  395. return msg(json.data.msg)
  396. }
  397. // console.log("第二次执行")
  398. let data = json.data.data;
  399. if (typeof data === 'string' && data.indexOf("{") === 0) {
  400. data = JSON.parse(data);
  401. }
  402. try{
  403. // 用户授权手机号日志
  404. if(url=='/api/weixin/mobile'){
  405. let sys = uni.getSystemInfoSync()
  406. let dataP = {
  407. type:3,
  408. model: sys.model,
  409. os: sys.osName,
  410. osVersion: sys.osVersion
  411. }
  412. postRequest('/api/log/authorize/save',dataP,res=>{
  413. })
  414. }
  415. // 用户授权昵称头像日志
  416. if(url=='/api/user/save' && (postData.avatar || postData.nickName || postData.cardNo || postData.areaAdd || postData.address)){
  417. let sys = uni.getSystemInfoSync()
  418. let dataP = {
  419. type:'',
  420. model: sys.model,
  421. os: sys.osName,
  422. osVersion: sys.osVersion
  423. }
  424. let dpt = []
  425. let dptcontent = []
  426. if(postData.nickName) {
  427. dpt.push(1)
  428. dptcontent.push(postData.nickName)
  429. }
  430. if(postData.avatar) {
  431. dpt.push(2)
  432. dptcontent.push(postData.avatar)
  433. }
  434. if(postData.cardNo) {
  435. dpt.push(4)
  436. dptcontent.push(postData.cardNo)
  437. }
  438. if(postData.areaAdd||postData.address) {
  439. dpt.push(5)
  440. dptcontent.push((postData.areaAdd?postData.areaAdd:'')+(postData.address?postData.address:''))
  441. }
  442. dataP.type = dpt.join(',')
  443. dataP.content = dptcontent.join(',')
  444. if(dpt.length>0){
  445. postRequest('/api/log/authorize/save',dataP,res=>{
  446. })
  447. }
  448. }
  449. }catch(e){
  450. //TODO handle the exception
  451. }
  452. success.call(this, data);
  453. },
  454. fail() {
  455. if (!isLoad) uni.hideNavigationBarLoading();
  456. },
  457. // complete(){
  458. // success.call(this, data);
  459. // },
  460. })
  461. })
  462. }
  463. const loadIng = (msg) => {
  464. uni.showLoading({
  465. title: msg,
  466. mask: true
  467. })
  468. }
  469. /**POST请求 */
  470. const postRequest = (url, data, success, isLoad) => {
  471. header['content-type'] = 'application/json;charset=UTF-8'
  472. baseRequest(url, data, 'post', success, isLoad);
  473. }
  474. const postRequestLoding = (url, data, success, isLoding) => {
  475. header['content-type'] = 'application/json;charset=UTF-8'
  476. baseRequest(url, data, 'post', success, false, isLoding);
  477. }
  478. /**GET请求 */
  479. const getRequest = (url, data, success, isLoad) => {
  480. header['content-type'] = 'application/json;charset=UTF-8'
  481. baseRequest(url, data, 'get', success, isLoad);
  482. }
  483. /**Put请求 */
  484. const putRequest = (url, data, success, isLoad) => {
  485. header['content-type'] = 'application/json;charset=UTF-8'
  486. baseRequest(url, data, 'put', success, isLoad)
  487. }
  488. const putRequestJson = (url, data, success, isLoad) => {
  489. header['content-type'] = 'application/json;charset=UTF-8'
  490. baseRequest(url, data, 'put', success, isLoad)
  491. }
  492. /**
  493. * 上传文件
  494. * @param {*} url 请求url
  495. * @param {*} data 携带数据
  496. * @param {*} success 请求成功函数
  497. */
  498. const uploadFile = (url, data, success) => {
  499. // console.log(env[env.NODE_ENV].apiUrl + url, data)
  500. getToken(token => {
  501. uni.uploadFile({
  502. url: env[env.NODE_ENV].apiUrl + url,
  503. filePath: data,
  504. name: 'file',
  505. header: {
  506. 'appId': header['appId'],
  507. 'authorityToken': token
  508. },
  509. success(res) {
  510. if (res.statusCode !== 200) return msg('文件上传失败');
  511. let data = JSON.parse(res.data);
  512. if (data.code !== 0) return msg(data.msg);
  513. success.call(this, data.data);
  514. },
  515. })
  516. })
  517. }
  518. /**弹窗 */
  519. const msg = (title, success) => {
  520. if (title) {
  521. uni.showToast({
  522. title: title,
  523. icon: 'none',
  524. success() {
  525. if (success) success.call(this);
  526. }
  527. });
  528. }
  529. return false;
  530. }
  531. const msgConfirm = (msg, success, cancel) => {
  532. uni.showModal({
  533. title: '提示',
  534. content: msg,
  535. success(res) {
  536. if (res.confirm) {
  537. success.call(this);
  538. } else {
  539. if (cancel) cancel.call(this);
  540. }
  541. }
  542. })
  543. }
  544. const msgConfirmText = (msg, confirmText, success, cancel) => {
  545. uni.showModal({
  546. title: '提示',
  547. content: msg,
  548. confirmText: confirmText,
  549. success(res) {
  550. if (res.confirm) {
  551. success.call(this);
  552. } else {
  553. if (cancel) cancel.call(this);
  554. }
  555. }
  556. })
  557. }
  558. const alertMsg = (msg, success) => {
  559. uni.showModal({
  560. title: '提示',
  561. content: msg,
  562. showCancel: false,
  563. success(res) {
  564. if (success) success.call(this);
  565. }
  566. })
  567. return false;
  568. }
  569. const load = msg => {
  570. uni.showLoading({
  571. title: msg,
  572. mask: true
  573. })
  574. }
  575. const g = (url, success, isLoad) => {
  576. getRequest(url, {}, success, isLoad)
  577. }
  578. const p = (url, success, isLoad) => {
  579. postRequest(url, {}, success, isLoad)
  580. }
  581. const send = (url, mobile, success, error) => {
  582. if (!mobile) {
  583. return msg('手机号码不能为空', error);
  584. }
  585. postRequest(url, {
  586. phone: mobile
  587. }, json => {
  588. if (json.code !== 0) {
  589. return msg(json.msg, error);
  590. }
  591. let time = 60;
  592. const initTime = setInterval(() => {
  593. time--;
  594. if (time > 0) {
  595. success.call(this, time + '秒后获取');
  596. } else {
  597. clearInterval(initTime);
  598. success.call(this, '获取验证码');
  599. }
  600. }, 1000)
  601. })
  602. }
  603. // 登陆拦截
  604. const redirectIndex = (params) => {
  605. // uni.clearStorageSync();
  606. // console.log(params)
  607. var pages = getCurrentPages();
  608. // console.log("pages》》》》》登陆拦截", pages);
  609. let currentUrl;
  610. if (pages) {
  611. var currentPage = pages[pages.length - 1];
  612. if (currentPage) {
  613. currentUrl = currentPage.route;
  614. let query = currentPage.data.query;
  615. if (query) {
  616. for (let key in query) {
  617. const fo = key + '=' + query[key];
  618. currentUrl += currentUrl.indexOf('?') > -1 ? '&' + fo : '?' + fo;
  619. }
  620. }
  621. if (currentUrl) {
  622. console.log('currentUrl》》》》》', currentUrl);
  623. setStorage("REDIRECT_URL", '/' + currentUrl)
  624. if (currentUrl == 'pages/authorize/authorize') {
  625. console.log('当前已经处于登录页面,不在向下执行跳转');
  626. return
  627. }
  628. }
  629. }
  630. }
  631. let redirectUrl = '/pages/authorize/authorize' + (params ? params : '');
  632. // console.log("登陆拦截")
  633. uni.navigateTo({
  634. url: redirectUrl
  635. })
  636. return false;
  637. }
  638. const saveImage = (url) => {
  639. uni.saveImageToPhotosAlbum({
  640. filePath: url,
  641. success() {
  642. msg('图片保存成功');
  643. }
  644. })
  645. }
  646. const saveImageToPhotosAlbum = (url) => {
  647. if (!url) return msg('小程序码不存在');
  648. uni.getImageInfo({
  649. src: url,
  650. success(json) {
  651. // uni.getSetting({
  652. // success(res) {
  653. // if (!res.authSetting['scope.writePhotosAlbum']) {
  654. // uni.authorize({
  655. // scope: 'scope.writePhotosAlbum',
  656. // success() {
  657. // saveImage(json.path);
  658. // }
  659. // })
  660. // } else {
  661. // saveImage(json.path);
  662. // }
  663. // }
  664. // })
  665. }
  666. })
  667. }
  668. const getConfig = (config, id) => {
  669. let con = {};
  670. config.info.forEach(inf => {
  671. // console.log(inf.version, inf.version ? inf.version.indexOf(id) : '-')
  672. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  673. con[inf.setName] = inf.setDefault;
  674. });
  675. config.card.forEach(inf => {
  676. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  677. con[inf.setName] = inf.setDefault;
  678. });
  679. config.realTime.forEach(inf => {
  680. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  681. con[inf.setName] = inf.setDefault;
  682. });
  683. return con;
  684. }
  685. const isLogin = async (error) => {
  686. let userInfo = getStorage('userInfo');
  687. if (!userInfo || !userInfo.id) {
  688. if (error) return false;
  689. // console.log("第一次执行")
  690. return redirectIndex();
  691. }
  692. return true;
  693. }
  694. //检测是否登录
  695. const isLogins = (isGoLogin) => {
  696. let userInfo = getStorage('userInfo');
  697. if (!userInfo) {
  698. if (isGoLogin) {
  699. redirectIndex();
  700. }
  701. return false;
  702. }
  703. return true;
  704. }
  705. const setStorage = (key, value) => {
  706. uni.setStorageSync(env.NODE_ENV + "_" + key, value)
  707. }
  708. const getStorage = (key) => {
  709. return uni.getStorageSync(env.NODE_ENV + "_" + key)
  710. }
  711. const removeStorage = (key) => {
  712. return uni.removeStorageSync(env.NODE_ENV + "_" + key);
  713. }
  714. /**
  715. * 缓存模板id
  716. */
  717. // const gettmplIds = () => {
  718. // getRequest('/api/wxmes/querylist', {}, res => {
  719. // setStorage('tmplIds', res)
  720. // console.log(res)
  721. // })
  722. // }
  723. //微信支付订单公共方法
  724. const payOrder = (id, success) => {
  725. var loctionAddressMap = getStorage('loctionAddressMap');
  726. var datas = {
  727. id: id
  728. };
  729. if (loctionAddressMap) {
  730. datas.province = loctionAddressMap.province;
  731. datas.city = loctionAddressMap.city;
  732. };
  733. if (getStorage('isVideoScene')) {
  734. uni.checkBeforeAddOrder({
  735. success(res) {
  736. console.log('下单前置检查', res)
  737. let data = res.data;
  738. data.requiredFundType = 0;
  739. datas.sceneCheckStr = JSON.stringify(data);
  740. wexinPay(datas, success)
  741. },
  742. })
  743. } else {
  744. wexinPay(datas, success)
  745. }
  746. }
  747. //支付中或已支付
  748. const payStatus = (json, id, success) => {
  749. if (json && json.code === 115) {
  750. setTimeout(res => {
  751. uni.hideLoading();
  752. isShowLoading = false;
  753. uni.showModal({
  754. title: '提示',
  755. content: '当前订单正在支付或30秒后重试',
  756. confirmText: '我知道了',
  757. showCancel: false,
  758. success(res) {}
  759. })
  760. }, 3000)
  761. return false;
  762. }
  763. if (json.type === 2 || json.type === 3) {
  764. //调用后台判断订单是否支付成功
  765. let i = 0;
  766. let timer = setInterval(() => {
  767. postRequest('/api/order/check', {
  768. id: id
  769. }, res => {
  770. if (res.isSuccess || i === 4) {
  771. clearInterval(timer);
  772. success.call(this, res.isSuccess);
  773. } else {
  774. i++;
  775. }
  776. }, true)
  777. }, 200);
  778. // success.call(this);
  779. return false;
  780. }
  781. }
  782. // 支付成功回调
  783. const paySuccess = (id, success) => {
  784. console.log('支付成功')
  785. let i = 0;
  786. let timer = setInterval(() => {
  787. postRequest('/api/order/check', {
  788. id: id
  789. }, res => {
  790. console.log(i)
  791. if (res.isSuccess || i === 5) {
  792. clearInterval(timer);
  793. success.call(this, res.isSuccess);
  794. } else {
  795. i++;
  796. }
  797. }, true)
  798. }, 500);
  799. }
  800. // 支付失败回调
  801. const payFail = (id) => {
  802. console.log('支付失败')
  803. postRequest('/api/order/cancelPay', {
  804. id: id
  805. }, data => {
  806. uni.redirectTo({
  807. url: '/mine/orderDet/orderDet?id=' + id,
  808. })
  809. })
  810. }
  811. const wexinPay = (datas, success) => {
  812. let isShowLoading = false;
  813. if (!isShowLoading) {
  814. loadIng('加载中');
  815. // console.log('加载中')
  816. isShowLoading = true;
  817. }
  818. // #ifdef MP-WEIXIN
  819. postRequest('/api/order/weixin/pay', datas, json => {
  820. // console.log('json',json)
  821. payStatus(json, datas.id, success)
  822. const sceneCheckStr = datas.sceneCheckStr;
  823. if (sceneCheckStr && JSON.parse(sceneCheckStr).requiredFundType === 1) {
  824. console.log('拉起收银台')
  825. wx.requestOrderPayment({
  826. timeStamp: json.timeStamp,
  827. nonceStr: json.nonceStr,
  828. package: json.packages,
  829. signType: json.signType,
  830. orderInfo: json.orderInfo,
  831. paySign: json.sign,
  832. success: function() {
  833. paySuccess(datas.id, success)
  834. },
  835. fail: function(res) {
  836. console.log(res);
  837. payFail(datas.id)
  838. }
  839. })
  840. } else {
  841. uni.requestPayment({
  842. timeStamp: json.timeStamp,
  843. nonceStr: json.nonceStr,
  844. package: json.packages,
  845. signType: json.signType,
  846. paySign: json.sign,
  847. success: function() {
  848. paySuccess(datas.id, success)
  849. },
  850. fail: function(res) {
  851. console.log(res);
  852. payFail(datas.id)
  853. }
  854. })
  855. }
  856. if (isShowLoading) {
  857. uni.hideLoading();
  858. isShowLoading = false;
  859. }
  860. })
  861. // #endif
  862. // #ifdef MP-ALIPAY
  863. datas.payChannel = 'alipay_lite ';
  864. postRequest('/api/order/weixin/pay', datas, json => {
  865. // console.log(json)
  866. if (json.type === 2 || json.type === 3) {
  867. //调用后台判断订单是否支付成功
  868. let i = 0;
  869. let timer = setInterval(() => {
  870. postRequest('/api/order/check', {
  871. id: id
  872. }, res => {
  873. if (res.isSuccess || i === 4) {
  874. clearInterval(timer);
  875. success.call(this, res.isSuccess);
  876. } else {
  877. i++;
  878. }
  879. }, true)
  880. }, 200);
  881. // success.call(this);
  882. return false;
  883. }
  884. uni.requestPayment({
  885. provider: 'alipay',
  886. orderInfo: json.packages,
  887. success: function() {
  888. paySuccess(datas.id, success)
  889. },
  890. fail: function(res) {
  891. payFail(datas.id)
  892. console.log(res);
  893. }
  894. })
  895. if (isShowLoading) {
  896. uni.hideLoading();
  897. isShowLoading = false;
  898. }
  899. })
  900. // #endif
  901. }
  902. //微信支付订单公共方法
  903. const payOrdersss = (id, success) => {
  904. let isShowLoading = false;
  905. if (!isShowLoading) {
  906. loadIng('加载中');
  907. // console.log('加载中')
  908. isShowLoading = true;
  909. }
  910. var loctionAddressMap = getStorage('loctionAddressMap');
  911. var datas = {
  912. id: id
  913. };
  914. if (loctionAddressMap) {
  915. datas.province = loctionAddressMap.province;
  916. datas.city = loctionAddressMap.city;
  917. };
  918. // #ifdef MP-WEIXIN
  919. postRequest('/api/order/weixin/pay', datas, json => {
  920. // console.log(json)
  921. if (json.type === 2 || json.type === 3) {
  922. //调用后台判断订单是否支付成功
  923. let i = 0;
  924. let timer = setInterval(() => {
  925. postRequest('/api/order/check', {
  926. id: id
  927. }, res => {
  928. if (res.isSuccess || i === 4) {
  929. clearInterval(timer);
  930. success.call(this, res.isSuccess);
  931. } else {
  932. i++;
  933. }
  934. }, true)
  935. }, 200);
  936. // success.call(this);
  937. return false;
  938. }
  939. uni.requestPayment({
  940. timeStamp: json.timeStamp,
  941. nonceStr: json.nonceStr,
  942. package: json.packages,
  943. signType: json.signType,
  944. paySign: json.sign,
  945. success: function() {
  946. console.log('支付成功')
  947. let i = 0;
  948. let timer = setInterval(() => {
  949. postRequest('/api/order/check', {
  950. id: id
  951. }, res => {
  952. console.log(i)
  953. if (res.isSuccess || i === 5) {
  954. clearInterval(timer);
  955. success.call(this, res.isSuccess);
  956. } else {
  957. i++;
  958. }
  959. }, true)
  960. }, 500);
  961. },
  962. fail: function(res) {
  963. console.log('支付失败')
  964. postRequest('/api/order/cancelPay', {
  965. id: id
  966. }, data => {
  967. uni.redirectTo({
  968. url: '/mine/orderDet/orderDet?id=' + id,
  969. })
  970. })
  971. console.log(res);
  972. }
  973. })
  974. if (isShowLoading) {
  975. uni.hideLoading();
  976. isShowLoading = false;
  977. }
  978. })
  979. // #endif
  980. // #ifdef MP-ALIPAY
  981. datas.payChannel = 'alipay_lite ';
  982. postRequest('/api/order/weixin/pay', datas, json => {
  983. // console.log(json)
  984. if (json.type === 2 || json.type === 3) {
  985. //调用后台判断订单是否支付成功
  986. let i = 0;
  987. let timer = setInterval(() => {
  988. postRequest('/api/order/check', {
  989. id: id
  990. }, res => {
  991. if (res.isSuccess || i === 4) {
  992. clearInterval(timer);
  993. success.call(this, res.isSuccess);
  994. } else {
  995. i++;
  996. }
  997. }, true)
  998. }, 200);
  999. // success.call(this);
  1000. return false;
  1001. }
  1002. uni.requestPayment({
  1003. provider: 'alipay',
  1004. orderInfo: json.packages,
  1005. success: function() {
  1006. console.log('支付成功')
  1007. let i = 0;
  1008. let timer = setInterval(() => {
  1009. postRequest('/api/order/check', {
  1010. id: id
  1011. }, res => {
  1012. console.log(i)
  1013. if (res.isSuccess || i === 5) {
  1014. clearInterval(timer);
  1015. success.call(this, res.isSuccess);
  1016. } else {
  1017. i++;
  1018. }
  1019. }, true)
  1020. }, 500);
  1021. },
  1022. fail: function(res) {
  1023. console.log('支付失败')
  1024. postRequest('/api/order/cancelPay', {
  1025. id: id
  1026. }, data => {
  1027. uni.redirectTo({
  1028. url: '/mine/orderDet/orderDet?id=' + id,
  1029. })
  1030. })
  1031. console.log(res);
  1032. }
  1033. })
  1034. if (isShowLoading) {
  1035. uni.hideLoading();
  1036. isShowLoading = false;
  1037. }
  1038. })
  1039. // #endif
  1040. }
  1041. //微信支付订单公共方法 ==活动
  1042. const payOrders = (id, success, type) => {
  1043. let isShowLoading = false;
  1044. if (!isShowLoading) {
  1045. loadIng('加载中');
  1046. // console.log('加载中')
  1047. isShowLoading = true;
  1048. }
  1049. postRequest('/api/order/weixin/pay', {
  1050. id: id
  1051. }, json => {
  1052. // console.log(json)
  1053. payStatus(json, id, success)
  1054. uni.requestPayment({
  1055. timeStamp: json.timeStamp,
  1056. nonceStr: json.nonceStr,
  1057. package: json.packages,
  1058. signType: json.signType,
  1059. paySign: json.sign,
  1060. success: function() {
  1061. paySuccess(id, success)
  1062. },
  1063. fail: function(res) {
  1064. console.log('支付失败')
  1065. postRequest('/api/order/cancelPay', {
  1066. id: id
  1067. }, data => {
  1068. uni.redirectTo({
  1069. url: '/mine/activity/activity',
  1070. })
  1071. })
  1072. console.log(res);
  1073. }
  1074. })
  1075. if (isShowLoading) {
  1076. uni.hideLoading();
  1077. isShowLoading = false;
  1078. }
  1079. })
  1080. }
  1081. const authSetting = (authority, success, error) => {
  1082. // console.log(authority,success)
  1083. // #ifndef H5
  1084. uni.getSetting({
  1085. success(res) {
  1086. if (res.authSetting[authority]) {
  1087. success.call(this);
  1088. return false;
  1089. }
  1090. uni.authorize({
  1091. scope: authority,
  1092. success() {
  1093. success.call(this);
  1094. },
  1095. fail: function(res) {
  1096. error.call(this);
  1097. }
  1098. })
  1099. }
  1100. })
  1101. // #endif
  1102. }
  1103. const getLocation = (suss) => {
  1104. // #ifdef MP-WEIXIN
  1105. authSetting('scope.userLocation', () => {
  1106. // load('定位中…');
  1107. uni.getLocation({
  1108. type: 'gcj02',
  1109. // isHighAccuracy: true,
  1110. success: function(res) {
  1111. // uni.hideLoading();
  1112. console.log(res, "789")
  1113. suss.call(this, res);
  1114. },
  1115. fail: function(res) {
  1116. console.log("调用失败", res)
  1117. suss.call(this, 2)
  1118. // uni.hideLoading();
  1119. }
  1120. })
  1121. }, () => {
  1122. // uni.hideLoading();
  1123. console.log("取消")
  1124. suss.call(this, 1)
  1125. });
  1126. // #endif
  1127. // #ifdef MP-ALIPAY
  1128. uni.getLocation({
  1129. type: 'gcj02',
  1130. // isHighAccuracy: true,
  1131. success: function(res) {
  1132. // uni.hideLoading();
  1133. console.log(res, "789")
  1134. suss.call(this, res);
  1135. },
  1136. fail: function(res) {
  1137. console.log("调用失败", res)
  1138. suss.call(this, 2)
  1139. // uni.hideLoading();
  1140. }
  1141. })
  1142. // #endif
  1143. // #ifdef H5
  1144. uni.getLocation({
  1145. type: 'gcj02',
  1146. isHighAccuracy: true,
  1147. success: function(res) {
  1148. // uni.hideLoading();
  1149. console.log(res)
  1150. suss.call(this, res, "789");
  1151. },
  1152. fail: function() {
  1153. console.log("调用失败", res)
  1154. suss.call(this, 2)
  1155. // uni.hideLoading();
  1156. }
  1157. })
  1158. // #endif
  1159. }
  1160. const scopeAddress = (success) => {
  1161. // #ifdef MP-WEIXIN
  1162. authSetting('scope.address', () => {
  1163. uni.chooseAddress({
  1164. success: function(res) {
  1165. success.call(this, res);
  1166. },
  1167. })
  1168. }, () => {
  1169. msg('未设置开放权限')
  1170. });
  1171. // #endif
  1172. // #ifdef MP-ALIPAY
  1173. uni.chooseAddress({
  1174. success: function(res) {
  1175. success.call(this, res);
  1176. },
  1177. })
  1178. // #endif
  1179. }
  1180. const isAuth = () => {
  1181. const user = getStorage('userInfo');
  1182. return user && user.id;
  1183. }
  1184. // 去掉字符串中的特殊字符和转义字符
  1185. const excludeSpecial = (s) => {
  1186. // 去掉转义字符
  1187. // s = s.replace(/[\'\"\\\/\b\f\n\r\t]/g, '');
  1188. const pattern = /[`~!@#$^&*()=|{}':;',\\\[\]\.<>\/?~!@#¥……&*()——|{}【】';:""' + - - _ % 。,、?\s]/g;
  1189. if (s != undefined || s != null) {
  1190. s = s.replace(pattern, "")
  1191. }
  1192. return s;
  1193. }
  1194. // 数字单位格式化
  1195. function unitConverter(num) {
  1196. // text 数字+单位 number格式化后的数字 unit单位
  1197. console.log(num)
  1198. if (!num || isNaN(num)) {
  1199. return {
  1200. text: 0,
  1201. number: 0,
  1202. unit: ''
  1203. }
  1204. }
  1205. num = Number(num)
  1206. if (Math.abs(num) > 100000000) {
  1207. return {
  1208. text: (num / 100000000).toFixed(2) + '亿',
  1209. number: (num / 100000000).toFixed(2),
  1210. unit: '亿'
  1211. }
  1212. } else if (Math.abs(num) > 10000) {
  1213. return {
  1214. text: (num / 10000).toFixed(2) + '万',
  1215. number: (num / 10000).toFixed(2),
  1216. unit: '万'
  1217. }
  1218. } else {
  1219. return {
  1220. text: num,
  1221. number: num,
  1222. unit: ''
  1223. }
  1224. }
  1225. }
  1226. // 行为操作
  1227. const saveBehavior = (params, success) => {
  1228. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1229. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1230. postRequest('/api/v3/behavior/save', params, data => {
  1231. success.call(this, data)
  1232. })
  1233. }
  1234. const getBehavior = (params, success) => {
  1235. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1236. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1237. console.log('行为')
  1238. getRequest('/api/v3/behavior/get', params, data => {
  1239. success.call(this, data)
  1240. })
  1241. }
  1242. /**
  1243. * @Description:
  1244. * @author: xionghaojie
  1245. * @param bindId 操作对象ID(如果是页面不需要传)
  1246. * @param type 用户行为操作对象(1.名片 2.活动 3.文章 4.社区页面 5.海报 6.点击发现页面 7.点击首页页面 8.点击我的页面 10.聊一聊 11.电话 12.微信 13.通讯录 14.评价名片)
  1247. * @param behavior 用户行为(1.关注 2.收藏 3.点赞 4.浏览 5.确认 6.分享 7.发布 8.评价 9.投票 10.点击 11.取消关注 12.取消点赞 13.评价 14.保存通讯录 15.聊一聊 16.加入)
  1248. * @param content 用户行为内容(非必填)
  1249. * @param shareUid 用户打开浏览时转发人id(非必填)
  1250. * @param browsingDuration 用户浏览时长(非必填,单位s)
  1251. * @return
  1252. * @createTime: 2023-10-16 10:48:32
  1253. */
  1254. const saveBehaviorNew = async (bindId,type,behavior,content, success,shareUid,browsingDuration) => {
  1255. let params = {
  1256. uid:'',
  1257. bindId:bindId,
  1258. behavior:behavior,
  1259. type:type,
  1260. ip:'',//ip
  1261. manufacturer:'',
  1262. model:'',//设备型号
  1263. os:'',//操作系统
  1264. osVersion:'',//操作系统版本
  1265. shareUid:shareUid?shareUid:'',
  1266. browsingDuration:browsingDuration?browsingDuration:''
  1267. }
  1268. await new Promise((resolve,reject)=>{
  1269. uni.getSystemInfoAsync({
  1270. success(res) {
  1271. console.log(res)
  1272. params.manufacturer = res.brand //手机牌子
  1273. params.model = res.model
  1274. params.os = res.system
  1275. params.osVersion = res.version
  1276. resolve()
  1277. },
  1278. fail(error){
  1279. console.log('getSystemInfoSync error',error)
  1280. resolve()
  1281. }
  1282. })
  1283. })
  1284. params.uid = getStorage('userInfo')?getStorage('userInfo').id:''
  1285. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1286. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1287. postRequest('/api/behaviorNew/save', params, data => {
  1288. if(success)
  1289. success.call(this, data)
  1290. })
  1291. }
  1292. /**
  1293. * 跳入聊天
  1294. * @param {Object} userId 对方用户ID
  1295. * @param {Object} avatar 对方用户头像
  1296. * @param {Object} realName 对方用户名称
  1297. */
  1298. const jumpSingleChatRoom = function(userId, avatar, realName) {
  1299. var my = uni.getStorageSync("myUsername");
  1300. var nameList = {
  1301. myName: my,
  1302. your: 'rs_' + userId
  1303. };
  1304. uni.setStorage({
  1305. key: 'imUserInfo_' + nameList.your,
  1306. data: {
  1307. avatar: avatar,
  1308. id: userId,
  1309. nickName: realName
  1310. }
  1311. });
  1312. uni.navigateTo({
  1313. url: "/chat/chatroom/chatroom?username=" + JSON.stringify(nameList)
  1314. });
  1315. }
  1316. /**
  1317. * text:展示导航名
  1318. * iconPath:未点击显示图标
  1319. * selectedIconPath:选中图标
  1320. * pagePath:页面路径
  1321. * channel:匹配名
  1322. * click:点击事件
  1323. * index:排序
  1324. * show:是否显示
  1325. */
  1326. var selectedIconPath
  1327. if (header.appId == 'ZQ1VK5oc17I387E') {
  1328. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'yunyao_h.png'
  1329. } else {
  1330. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'home_h.png'
  1331. }
  1332. var tab = [{
  1333. text: "首页",
  1334. iconPath: "/static/pages/images/home.png",
  1335. selectedIconPath: '/static/pages/images/home_h.png',
  1336. pagePath: 'pages/index/index',
  1337. channel: 'home',
  1338. click: 'goHome',
  1339. index: 1,
  1340. show: true
  1341. },
  1342. {
  1343. text: "活动",
  1344. iconPath: "/static/pages/images/activity.png",
  1345. selectedIconPath: '/static/pages/images/activity_h.png',
  1346. pagePath: 'pages/matchList/index',
  1347. click: 'goMatch',
  1348. channel: 'match',
  1349. index: 2,
  1350. show: true
  1351. },
  1352. {
  1353. text: "社区",
  1354. iconPath: "/static/pages/images/interactive.png",
  1355. selectedIconPath: '/static/pages/images/interactive_h.png',
  1356. pagePath: 'pages/interactive/index',
  1357. click: 'goInteractive',
  1358. channel: 'interactive',
  1359. index: 3,
  1360. show: true
  1361. },
  1362. {
  1363. text: "发现",
  1364. iconPath: "/static/pages/images/found.png",
  1365. selectedIconPath: '/static/pages/images/found_h.png',
  1366. pagePath: 'pages/found/found',
  1367. click: 'goFound',
  1368. channel: 'found',
  1369. index: 3,
  1370. show: true
  1371. },
  1372. {
  1373. text: "我的",
  1374. iconPath: '/static/pages/images/user.png',
  1375. selectedIconPath: '/static/pages/images/user_h.png',
  1376. pagePath: 'pages/user/user',
  1377. click: 'goUser',
  1378. channel: 'user',
  1379. index: 6,
  1380. show: true
  1381. }
  1382. ]
  1383. module.exports = {
  1384. setStorage: setStorage,
  1385. getStorage: getStorage,
  1386. postRequest: postRequest,
  1387. postRequestLoding: postRequestLoding,
  1388. getRequest: getRequest,
  1389. putRequest: putRequest,
  1390. putRequestJson: putRequestJson,
  1391. msg: msg,
  1392. g: g,
  1393. p: p,
  1394. env: env,
  1395. send: send,
  1396. redirectIndex: redirectIndex,
  1397. saveImage: saveImage,
  1398. saveImageToPhotosAlbum: saveImageToPhotosAlbum,
  1399. uploadFile: uploadFile,
  1400. msgConfirm: msgConfirm,
  1401. getConfig: getConfig,
  1402. load: load,
  1403. isLogin: isLogin,
  1404. isLogins: isLogins,
  1405. payOrder: payOrder,
  1406. payOrders: payOrders,
  1407. getLocation: getLocation,
  1408. scopeAddress: scopeAddress,
  1409. isAuth: isAuth,
  1410. alertMsg: alertMsg,
  1411. getToken: getToken,
  1412. loadIng: loadIng,
  1413. removeStorage: removeStorage,
  1414. public: publics,
  1415. header: header,
  1416. // gettmplIds: gettmplIds,
  1417. excludeSpecial: excludeSpecial,
  1418. tab: tab,
  1419. msgConfirmText: msgConfirmText,
  1420. silenceLogin: silenceLogin,
  1421. getWXUserProfile: getWXUserProfile,
  1422. updataWxInfos: updataWxInfos,
  1423. saveBehavior: saveBehavior,
  1424. getBehavior: getBehavior,
  1425. saveBehaviorNew:saveBehaviorNew,
  1426. unitConverter: unitConverter,
  1427. initIMChat: initIMChat,
  1428. getIMToken: getIMToken,
  1429. jumpConversation: jumpConversation,
  1430. jumpSingleChatRoom: jumpSingleChatRoom,
  1431. getsysConfig:getsysConfig
  1432. }