request.js 36 KB

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