request.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  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: 'dev',
  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. 'channel': '', //处方中间渠道号 SAAS系统为空
  33. 'mapLBSKEY': 'CBRBZ-5SHKL-3NCPX-EP5MQ-B57M6-CWFUU',
  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'){
  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)){
  417. let sys = uni.getSystemInfoSync()
  418. let dataP = {
  419. type:'',
  420. model: sys.model,
  421. os: sys.osName,
  422. osVersion: sys.osVersion
  423. }
  424. if(postData.avatar&&postData.nickName) dataP.type = '1,2'
  425. else if(postData.nickName) dataP.type = '1'
  426. else if(postData.avatar) dataP.type = '2'
  427. postRequest('/api/log/authorize/save',dataP,res=>{
  428. })
  429. }
  430. }catch(e){
  431. //TODO handle the exception
  432. }
  433. success.call(this, data);
  434. },
  435. fail() {
  436. if (!isLoad) uni.hideNavigationBarLoading();
  437. },
  438. // complete(){
  439. // success.call(this, data);
  440. // },
  441. })
  442. })
  443. }
  444. const loadIng = (msg) => {
  445. uni.showLoading({
  446. title: msg,
  447. mask: true
  448. })
  449. }
  450. /**POST请求 */
  451. const postRequest = (url, data, success, isLoad) => {
  452. header['content-type'] = 'application/json;charset=UTF-8'
  453. baseRequest(url, data, 'post', success, isLoad);
  454. }
  455. const postRequestLoding = (url, data, success, isLoding) => {
  456. header['content-type'] = 'application/json;charset=UTF-8'
  457. baseRequest(url, data, 'post', success, false, isLoding);
  458. }
  459. /**GET请求 */
  460. const getRequest = (url, data, success, isLoad) => {
  461. header['content-type'] = 'application/json;charset=UTF-8'
  462. baseRequest(url, data, 'get', success, isLoad);
  463. }
  464. /**Put请求 */
  465. const putRequest = (url, data, success, isLoad) => {
  466. header['content-type'] = 'application/json;charset=UTF-8'
  467. baseRequest(url, data, 'put', success, isLoad)
  468. }
  469. const putRequestJson = (url, data, success, isLoad) => {
  470. header['content-type'] = 'application/json;charset=UTF-8'
  471. baseRequest(url, data, 'put', success, isLoad)
  472. }
  473. /**
  474. * 上传文件
  475. * @param {*} url 请求url
  476. * @param {*} data 携带数据
  477. * @param {*} success 请求成功函数
  478. */
  479. const uploadFile = (url, data, success) => {
  480. // console.log(env[env.NODE_ENV].apiUrl + url, data)
  481. getToken(token => {
  482. uni.uploadFile({
  483. url: env[env.NODE_ENV].apiUrl + url,
  484. filePath: data,
  485. name: 'file',
  486. header: {
  487. 'appId': header['appId'],
  488. 'authorityToken': token
  489. },
  490. success(res) {
  491. if (res.statusCode !== 200) return msg('文件上传失败');
  492. let data = JSON.parse(res.data);
  493. if (data.code !== 0) return msg(data.msg);
  494. success.call(this, data.data);
  495. },
  496. })
  497. })
  498. }
  499. /**弹窗 */
  500. const msg = (title, success) => {
  501. if (title) {
  502. uni.showToast({
  503. title: title,
  504. icon: 'none',
  505. success() {
  506. if (success) success.call(this);
  507. }
  508. });
  509. }
  510. return false;
  511. }
  512. const msgConfirm = (msg, success, cancel) => {
  513. uni.showModal({
  514. title: '提示',
  515. content: msg,
  516. success(res) {
  517. if (res.confirm) {
  518. success.call(this);
  519. } else {
  520. if (cancel) cancel.call(this);
  521. }
  522. }
  523. })
  524. }
  525. const msgConfirmText = (msg, confirmText, success, cancel) => {
  526. uni.showModal({
  527. title: '提示',
  528. content: msg,
  529. confirmText: confirmText,
  530. success(res) {
  531. if (res.confirm) {
  532. success.call(this);
  533. } else {
  534. if (cancel) cancel.call(this);
  535. }
  536. }
  537. })
  538. }
  539. const alertMsg = (msg, success) => {
  540. uni.showModal({
  541. title: '提示',
  542. content: msg,
  543. showCancel: false,
  544. success(res) {
  545. if (success) success.call(this);
  546. }
  547. })
  548. return false;
  549. }
  550. const load = msg => {
  551. uni.showLoading({
  552. title: msg,
  553. mask: true
  554. })
  555. }
  556. const g = (url, success, isLoad) => {
  557. getRequest(url, {}, success, isLoad)
  558. }
  559. const p = (url, success, isLoad) => {
  560. postRequest(url, {}, success, isLoad)
  561. }
  562. const send = (url, mobile, success, error) => {
  563. if (!mobile) {
  564. return msg('手机号码不能为空', error);
  565. }
  566. postRequest(url, {
  567. phone: mobile
  568. }, json => {
  569. if (json.code !== 0) {
  570. return msg(json.msg, error);
  571. }
  572. let time = 60;
  573. const initTime = setInterval(() => {
  574. time--;
  575. if (time > 0) {
  576. success.call(this, time + '秒后获取');
  577. } else {
  578. clearInterval(initTime);
  579. success.call(this, '获取验证码');
  580. }
  581. }, 1000)
  582. })
  583. }
  584. // 登陆拦截
  585. const redirectIndex = (params) => {
  586. // uni.clearStorageSync();
  587. // console.log(params)
  588. var pages = getCurrentPages();
  589. // console.log("pages》》》》》登陆拦截", pages);
  590. let currentUrl;
  591. if (pages) {
  592. var currentPage = pages[pages.length - 1];
  593. if (currentPage) {
  594. currentUrl = currentPage.route;
  595. let query = currentPage.data.query;
  596. if (query) {
  597. for (let key in query) {
  598. const fo = key + '=' + query[key];
  599. currentUrl += currentUrl.indexOf('?') > -1 ? '&' + fo : '?' + fo;
  600. }
  601. }
  602. if (currentUrl) {
  603. console.log('currentUrl》》》》》', currentUrl);
  604. setStorage("REDIRECT_URL", '/' + currentUrl)
  605. if (currentUrl == 'pages/authorize/authorize') {
  606. console.log('当前已经处于登录页面,不在向下执行跳转');
  607. return
  608. }
  609. }
  610. }
  611. }
  612. let redirectUrl = '/pages/authorize/authorize' + (params ? params : '');
  613. // console.log("登陆拦截")
  614. uni.navigateTo({
  615. url: redirectUrl
  616. })
  617. return false;
  618. }
  619. const saveImage = (url) => {
  620. uni.saveImageToPhotosAlbum({
  621. filePath: url,
  622. success() {
  623. msg('图片保存成功');
  624. }
  625. })
  626. }
  627. const saveImageToPhotosAlbum = (url) => {
  628. if (!url) return msg('小程序码不存在');
  629. uni.getImageInfo({
  630. src: url,
  631. success(json) {
  632. // uni.getSetting({
  633. // success(res) {
  634. // if (!res.authSetting['scope.writePhotosAlbum']) {
  635. // uni.authorize({
  636. // scope: 'scope.writePhotosAlbum',
  637. // success() {
  638. // saveImage(json.path);
  639. // }
  640. // })
  641. // } else {
  642. // saveImage(json.path);
  643. // }
  644. // }
  645. // })
  646. }
  647. })
  648. }
  649. const getConfig = (config, id) => {
  650. let con = {};
  651. config.info.forEach(inf => {
  652. // console.log(inf.version, inf.version ? inf.version.indexOf(id) : '-')
  653. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  654. con[inf.setName] = inf.setDefault;
  655. });
  656. config.card.forEach(inf => {
  657. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  658. con[inf.setName] = inf.setDefault;
  659. });
  660. config.realTime.forEach(inf => {
  661. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  662. con[inf.setName] = inf.setDefault;
  663. });
  664. return con;
  665. }
  666. const isLogin = async (error) => {
  667. let userInfo = getStorage('userInfo');
  668. if (!userInfo || !userInfo.id) {
  669. if (error) return false;
  670. // console.log("第一次执行")
  671. return redirectIndex();
  672. }
  673. return true;
  674. }
  675. //检测是否登录
  676. const isLogins = (isGoLogin) => {
  677. let userInfo = getStorage('userInfo');
  678. if (!userInfo) {
  679. if (isGoLogin) {
  680. redirectIndex();
  681. }
  682. return false;
  683. }
  684. return true;
  685. }
  686. const setStorage = (key, value) => {
  687. uni.setStorageSync(env.NODE_ENV + "_" + key, value)
  688. }
  689. const getStorage = (key) => {
  690. return uni.getStorageSync(env.NODE_ENV + "_" + key)
  691. }
  692. const removeStorage = (key) => {
  693. return uni.removeStorageSync(env.NODE_ENV + "_" + key);
  694. }
  695. /**
  696. * 缓存模板id
  697. */
  698. // const gettmplIds = () => {
  699. // getRequest('/api/wxmes/querylist', {}, res => {
  700. // setStorage('tmplIds', res)
  701. // console.log(res)
  702. // })
  703. // }
  704. //微信支付订单公共方法
  705. const payOrder = (id, success) => {
  706. var loctionAddressMap = getStorage('loctionAddressMap');
  707. var datas = {
  708. id: id
  709. };
  710. if (loctionAddressMap) {
  711. datas.province = loctionAddressMap.province;
  712. datas.city = loctionAddressMap.city;
  713. };
  714. if (getStorage('isVideoScene')) {
  715. uni.checkBeforeAddOrder({
  716. success(res) {
  717. console.log('下单前置检查', res)
  718. let data = res.data;
  719. data.requiredFundType = 0;
  720. datas.sceneCheckStr = JSON.stringify(data);
  721. wexinPay(datas, success)
  722. },
  723. })
  724. } else {
  725. wexinPay(datas, success)
  726. }
  727. }
  728. //支付中或已支付
  729. const payStatus = (json, id, success) => {
  730. if (json && json.code === 115) {
  731. setTimeout(res => {
  732. uni.hideLoading();
  733. isShowLoading = false;
  734. uni.showModal({
  735. title: '提示',
  736. content: '当前订单正在支付或30秒后重试',
  737. confirmText: '我知道了',
  738. showCancel: false,
  739. success(res) {}
  740. })
  741. }, 3000)
  742. return false;
  743. }
  744. if (json.type === 2 || json.type === 3) {
  745. //调用后台判断订单是否支付成功
  746. let i = 0;
  747. let timer = setInterval(() => {
  748. postRequest('/api/order/check', {
  749. id: id
  750. }, res => {
  751. if (res.isSuccess || i === 4) {
  752. clearInterval(timer);
  753. success.call(this, res.isSuccess);
  754. } else {
  755. i++;
  756. }
  757. }, true)
  758. }, 200);
  759. // success.call(this);
  760. return false;
  761. }
  762. }
  763. // 支付成功回调
  764. const paySuccess = (id, success) => {
  765. console.log('支付成功')
  766. let i = 0;
  767. let timer = setInterval(() => {
  768. postRequest('/api/order/check', {
  769. id: id
  770. }, res => {
  771. console.log(i)
  772. if (res.isSuccess || i === 5) {
  773. clearInterval(timer);
  774. success.call(this, res.isSuccess);
  775. } else {
  776. i++;
  777. }
  778. }, true)
  779. }, 500);
  780. }
  781. // 支付失败回调
  782. const payFail = (id) => {
  783. console.log('支付失败')
  784. postRequest('/api/order/cancelPay', {
  785. id: id
  786. }, data => {
  787. uni.redirectTo({
  788. url: '/mine/orderDet/orderDet?id=' + id,
  789. })
  790. })
  791. }
  792. const wexinPay = (datas, success) => {
  793. let isShowLoading = false;
  794. if (!isShowLoading) {
  795. loadIng('加载中');
  796. // console.log('加载中')
  797. isShowLoading = true;
  798. }
  799. // #ifdef MP-WEIXIN
  800. postRequest('/api/order/weixin/pay', datas, json => {
  801. // console.log('json',json)
  802. payStatus(json, datas.id, success)
  803. const sceneCheckStr = datas.sceneCheckStr;
  804. if (sceneCheckStr && JSON.parse(sceneCheckStr).requiredFundType === 1) {
  805. console.log('拉起收银台')
  806. wx.requestOrderPayment({
  807. timeStamp: json.timeStamp,
  808. nonceStr: json.nonceStr,
  809. package: json.packages,
  810. signType: json.signType,
  811. orderInfo: json.orderInfo,
  812. paySign: json.sign,
  813. success: function() {
  814. paySuccess(datas.id, success)
  815. },
  816. fail: function(res) {
  817. console.log(res);
  818. payFail(datas.id)
  819. }
  820. })
  821. } else {
  822. uni.requestPayment({
  823. timeStamp: json.timeStamp,
  824. nonceStr: json.nonceStr,
  825. package: json.packages,
  826. signType: json.signType,
  827. paySign: json.sign,
  828. success: function() {
  829. paySuccess(datas.id, success)
  830. },
  831. fail: function(res) {
  832. console.log(res);
  833. payFail(datas.id)
  834. }
  835. })
  836. }
  837. if (isShowLoading) {
  838. uni.hideLoading();
  839. isShowLoading = false;
  840. }
  841. })
  842. // #endif
  843. // #ifdef MP-ALIPAY
  844. datas.payChannel = 'alipay_lite ';
  845. postRequest('/api/order/weixin/pay', datas, json => {
  846. // console.log(json)
  847. if (json.type === 2 || json.type === 3) {
  848. //调用后台判断订单是否支付成功
  849. let i = 0;
  850. let timer = setInterval(() => {
  851. postRequest('/api/order/check', {
  852. id: id
  853. }, res => {
  854. if (res.isSuccess || i === 4) {
  855. clearInterval(timer);
  856. success.call(this, res.isSuccess);
  857. } else {
  858. i++;
  859. }
  860. }, true)
  861. }, 200);
  862. // success.call(this);
  863. return false;
  864. }
  865. uni.requestPayment({
  866. provider: 'alipay',
  867. orderInfo: json.packages,
  868. success: function() {
  869. paySuccess(datas.id, success)
  870. },
  871. fail: function(res) {
  872. payFail(datas.id)
  873. console.log(res);
  874. }
  875. })
  876. if (isShowLoading) {
  877. uni.hideLoading();
  878. isShowLoading = false;
  879. }
  880. })
  881. // #endif
  882. }
  883. //微信支付订单公共方法
  884. const payOrdersss = (id, success) => {
  885. let isShowLoading = false;
  886. if (!isShowLoading) {
  887. loadIng('加载中');
  888. // console.log('加载中')
  889. isShowLoading = true;
  890. }
  891. var loctionAddressMap = getStorage('loctionAddressMap');
  892. var datas = {
  893. id: id
  894. };
  895. if (loctionAddressMap) {
  896. datas.province = loctionAddressMap.province;
  897. datas.city = loctionAddressMap.city;
  898. };
  899. // #ifdef MP-WEIXIN
  900. postRequest('/api/order/weixin/pay', datas, json => {
  901. // console.log(json)
  902. if (json.type === 2 || json.type === 3) {
  903. //调用后台判断订单是否支付成功
  904. let i = 0;
  905. let timer = setInterval(() => {
  906. postRequest('/api/order/check', {
  907. id: id
  908. }, res => {
  909. if (res.isSuccess || i === 4) {
  910. clearInterval(timer);
  911. success.call(this, res.isSuccess);
  912. } else {
  913. i++;
  914. }
  915. }, true)
  916. }, 200);
  917. // success.call(this);
  918. return false;
  919. }
  920. uni.requestPayment({
  921. timeStamp: json.timeStamp,
  922. nonceStr: json.nonceStr,
  923. package: json.packages,
  924. signType: json.signType,
  925. paySign: json.sign,
  926. success: function() {
  927. console.log('支付成功')
  928. let i = 0;
  929. let timer = setInterval(() => {
  930. postRequest('/api/order/check', {
  931. id: id
  932. }, res => {
  933. console.log(i)
  934. if (res.isSuccess || i === 5) {
  935. clearInterval(timer);
  936. success.call(this, res.isSuccess);
  937. } else {
  938. i++;
  939. }
  940. }, true)
  941. }, 500);
  942. },
  943. fail: function(res) {
  944. console.log('支付失败')
  945. postRequest('/api/order/cancelPay', {
  946. id: id
  947. }, data => {
  948. uni.redirectTo({
  949. url: '/mine/orderDet/orderDet?id=' + id,
  950. })
  951. })
  952. console.log(res);
  953. }
  954. })
  955. if (isShowLoading) {
  956. uni.hideLoading();
  957. isShowLoading = false;
  958. }
  959. })
  960. // #endif
  961. // #ifdef MP-ALIPAY
  962. datas.payChannel = 'alipay_lite ';
  963. postRequest('/api/order/weixin/pay', datas, json => {
  964. // console.log(json)
  965. if (json.type === 2 || json.type === 3) {
  966. //调用后台判断订单是否支付成功
  967. let i = 0;
  968. let timer = setInterval(() => {
  969. postRequest('/api/order/check', {
  970. id: id
  971. }, res => {
  972. if (res.isSuccess || i === 4) {
  973. clearInterval(timer);
  974. success.call(this, res.isSuccess);
  975. } else {
  976. i++;
  977. }
  978. }, true)
  979. }, 200);
  980. // success.call(this);
  981. return false;
  982. }
  983. uni.requestPayment({
  984. provider: 'alipay',
  985. orderInfo: json.packages,
  986. success: function() {
  987. console.log('支付成功')
  988. let i = 0;
  989. let timer = setInterval(() => {
  990. postRequest('/api/order/check', {
  991. id: id
  992. }, res => {
  993. console.log(i)
  994. if (res.isSuccess || i === 5) {
  995. clearInterval(timer);
  996. success.call(this, res.isSuccess);
  997. } else {
  998. i++;
  999. }
  1000. }, true)
  1001. }, 500);
  1002. },
  1003. fail: function(res) {
  1004. console.log('支付失败')
  1005. postRequest('/api/order/cancelPay', {
  1006. id: id
  1007. }, data => {
  1008. uni.redirectTo({
  1009. url: '/mine/orderDet/orderDet?id=' + id,
  1010. })
  1011. })
  1012. console.log(res);
  1013. }
  1014. })
  1015. if (isShowLoading) {
  1016. uni.hideLoading();
  1017. isShowLoading = false;
  1018. }
  1019. })
  1020. // #endif
  1021. }
  1022. //微信支付订单公共方法 ==活动
  1023. const payOrders = (id, success, type) => {
  1024. let isShowLoading = false;
  1025. if (!isShowLoading) {
  1026. loadIng('加载中');
  1027. // console.log('加载中')
  1028. isShowLoading = true;
  1029. }
  1030. postRequest('/api/order/weixin/pay', {
  1031. id: id
  1032. }, json => {
  1033. // console.log(json)
  1034. payStatus(json, id, success)
  1035. uni.requestPayment({
  1036. timeStamp: json.timeStamp,
  1037. nonceStr: json.nonceStr,
  1038. package: json.packages,
  1039. signType: json.signType,
  1040. paySign: json.sign,
  1041. success: function() {
  1042. paySuccess(id, success)
  1043. },
  1044. fail: function(res) {
  1045. console.log('支付失败')
  1046. postRequest('/api/order/cancelPay', {
  1047. id: id
  1048. }, data => {
  1049. uni.redirectTo({
  1050. url: '/mine/activity/activity',
  1051. })
  1052. })
  1053. console.log(res);
  1054. }
  1055. })
  1056. if (isShowLoading) {
  1057. uni.hideLoading();
  1058. isShowLoading = false;
  1059. }
  1060. })
  1061. }
  1062. const authSetting = (authority, success, error) => {
  1063. // console.log(authority,success)
  1064. // #ifndef H5
  1065. uni.getSetting({
  1066. success(res) {
  1067. if (res.authSetting[authority]) {
  1068. success.call(this);
  1069. return false;
  1070. }
  1071. uni.authorize({
  1072. scope: authority,
  1073. success() {
  1074. success.call(this);
  1075. },
  1076. fail: function(res) {
  1077. error.call(this);
  1078. }
  1079. })
  1080. }
  1081. })
  1082. // #endif
  1083. }
  1084. const getLocation = (suss) => {
  1085. // #ifdef MP-WEIXIN
  1086. authSetting('scope.userLocation', () => {
  1087. // load('定位中…');
  1088. uni.getLocation({
  1089. type: 'gcj02',
  1090. // isHighAccuracy: true,
  1091. success: function(res) {
  1092. // uni.hideLoading();
  1093. console.log(res, "789")
  1094. suss.call(this, res);
  1095. },
  1096. fail: function(res) {
  1097. console.log("调用失败", res)
  1098. suss.call(this, 2)
  1099. // uni.hideLoading();
  1100. }
  1101. })
  1102. }, () => {
  1103. // uni.hideLoading();
  1104. console.log("取消")
  1105. suss.call(this, 1)
  1106. });
  1107. // #endif
  1108. // #ifdef MP-ALIPAY
  1109. uni.getLocation({
  1110. type: 'gcj02',
  1111. // isHighAccuracy: true,
  1112. success: function(res) {
  1113. // uni.hideLoading();
  1114. console.log(res, "789")
  1115. suss.call(this, res);
  1116. },
  1117. fail: function(res) {
  1118. console.log("调用失败", res)
  1119. suss.call(this, 2)
  1120. // uni.hideLoading();
  1121. }
  1122. })
  1123. // #endif
  1124. // #ifdef H5
  1125. uni.getLocation({
  1126. type: 'gcj02',
  1127. isHighAccuracy: true,
  1128. success: function(res) {
  1129. // uni.hideLoading();
  1130. console.log(res)
  1131. suss.call(this, res, "789");
  1132. },
  1133. fail: function() {
  1134. console.log("调用失败", res)
  1135. suss.call(this, 2)
  1136. // uni.hideLoading();
  1137. }
  1138. })
  1139. // #endif
  1140. }
  1141. const scopeAddress = (success) => {
  1142. // #ifdef MP-WEIXIN
  1143. authSetting('scope.address', () => {
  1144. uni.chooseAddress({
  1145. success: function(res) {
  1146. success.call(this, res);
  1147. },
  1148. })
  1149. }, () => {
  1150. msg('未设置开放权限')
  1151. });
  1152. // #endif
  1153. // #ifdef MP-ALIPAY
  1154. uni.chooseAddress({
  1155. success: function(res) {
  1156. success.call(this, res);
  1157. },
  1158. })
  1159. // #endif
  1160. }
  1161. const isAuth = () => {
  1162. const user = getStorage('userInfo');
  1163. return user && user.id;
  1164. }
  1165. // 去掉字符串中的特殊字符和转义字符
  1166. const excludeSpecial = (s) => {
  1167. // 去掉转义字符
  1168. // s = s.replace(/[\'\"\\\/\b\f\n\r\t]/g, '');
  1169. const pattern = /[`~!@#$^&*()=|{}':;',\\\[\]\.<>\/?~!@#¥……&*()——|{}【】';:""' + - - _ % 。,、?\s]/g;
  1170. if (s != undefined || s != null) {
  1171. s = s.replace(pattern, "")
  1172. }
  1173. return s;
  1174. }
  1175. // 数字单位格式化
  1176. function unitConverter(num) {
  1177. // text 数字+单位 number格式化后的数字 unit单位
  1178. console.log(num)
  1179. if (!num || isNaN(num)) {
  1180. return {
  1181. text: 0,
  1182. number: 0,
  1183. unit: ''
  1184. }
  1185. }
  1186. num = Number(num)
  1187. if (Math.abs(num) > 100000000) {
  1188. return {
  1189. text: (num / 100000000).toFixed(2) + '亿',
  1190. number: (num / 100000000).toFixed(2),
  1191. unit: '亿'
  1192. }
  1193. } else if (Math.abs(num) > 10000) {
  1194. return {
  1195. text: (num / 10000).toFixed(2) + '万',
  1196. number: (num / 10000).toFixed(2),
  1197. unit: '万'
  1198. }
  1199. } else {
  1200. return {
  1201. text: num,
  1202. number: num,
  1203. unit: ''
  1204. }
  1205. }
  1206. }
  1207. // 行为操作
  1208. const saveBehavior = (params, success) => {
  1209. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1210. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1211. postRequest('/api/v3/behavior/save', params, data => {
  1212. success.call(this, data)
  1213. })
  1214. }
  1215. const getBehavior = (params, success) => {
  1216. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1217. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1218. console.log('行为')
  1219. getRequest('/api/v3/behavior/get', params, data => {
  1220. success.call(this, data)
  1221. })
  1222. }
  1223. /**
  1224. * @Description:
  1225. * @author: xionghaojie
  1226. * @param bindId 操作对象ID(如果是页面不需要传)
  1227. * @param type 用户行为操作对象(1.名片 2.活动 3.文章 4.社区页面 5.海报 6.点击发现页面 7.点击首页页面 8.点击我的页面 10.聊一聊 11.电话 12.微信 13.通讯录 14.评价名片)
  1228. * @param behavior 用户行为(1.关注 2.收藏 3.点赞 4.浏览 5.确认 6.分享 7.发布 8.评价 9.投票 10.点击 11.取消关注 12.取消点赞 13.评价 14.保存通讯录 15.聊一聊 16.加入)
  1229. * @param content 用户行为内容(非必填)
  1230. * @return
  1231. * @createTime: 2023-10-16 10:48:32
  1232. */
  1233. const saveBehaviorNew = async (bindId,type,behavior,content, success) => {
  1234. let params = {
  1235. uid:'',
  1236. bindId:bindId,
  1237. behavior:behavior,
  1238. type:type,
  1239. ip:'',//ip
  1240. manufacturer:'',
  1241. model:'',//设备型号
  1242. os:'',//操作系统
  1243. osVersion:'',//操作系统版本
  1244. }
  1245. await new Promise((resolve,reject)=>{
  1246. uni.getSystemInfoAsync({
  1247. success(res) {
  1248. console.log(res)
  1249. params.manufacturer = res.brand //手机牌子
  1250. params.model = res.model
  1251. params.os = res.system
  1252. params.osVersion = res.version
  1253. resolve()
  1254. },
  1255. fail(error){
  1256. console.log('getSystemInfoSync error',error)
  1257. resolve()
  1258. }
  1259. })
  1260. })
  1261. params.uid = getStorage('userInfo')?getStorage('userInfo').id:''
  1262. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1263. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1264. postRequest('/api/behaviorNew/save', params, data => {
  1265. if(success)
  1266. success.call(this, data)
  1267. })
  1268. }
  1269. /**
  1270. * 跳入聊天
  1271. * @param {Object} userId 对方用户ID
  1272. * @param {Object} avatar 对方用户头像
  1273. * @param {Object} realName 对方用户名称
  1274. */
  1275. const jumpSingleChatRoom = function(userId, avatar, realName) {
  1276. var my = uni.getStorageSync("myUsername");
  1277. var nameList = {
  1278. myName: my,
  1279. your: 'rs_' + userId
  1280. };
  1281. uni.setStorage({
  1282. key: 'imUserInfo_' + nameList.your,
  1283. data: {
  1284. avatar: avatar,
  1285. id: userId,
  1286. nickName: realName
  1287. }
  1288. });
  1289. uni.navigateTo({
  1290. url: "/chat/chatroom/chatroom?username=" + JSON.stringify(nameList)
  1291. });
  1292. }
  1293. /**
  1294. * text:展示导航名
  1295. * iconPath:未点击显示图标
  1296. * selectedIconPath:选中图标
  1297. * pagePath:页面路径
  1298. * channel:匹配名
  1299. * click:点击事件
  1300. * index:排序
  1301. * show:是否显示
  1302. */
  1303. var selectedIconPath
  1304. if (header.appId == 'ZQ1VK5oc17I387E') {
  1305. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'yunyao_h.png'
  1306. } else {
  1307. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'home_h.png'
  1308. }
  1309. var tab = [{
  1310. text: "首页",
  1311. iconPath: "/static/pages/images/home.png",
  1312. selectedIconPath: '/static/pages/images/home_h.png',
  1313. pagePath: 'pages/index/index',
  1314. channel: 'home',
  1315. click: 'goHome',
  1316. index: 1,
  1317. show: true
  1318. },
  1319. {
  1320. text: "活动",
  1321. iconPath: "/static/pages/images/activity.png",
  1322. selectedIconPath: '/static/pages/images/activity_h.png',
  1323. pagePath: 'pages/matchList/index',
  1324. click: 'goMatch',
  1325. channel: 'match',
  1326. index: 2,
  1327. show: true
  1328. },
  1329. {
  1330. text: "社区",
  1331. iconPath: "/static/pages/images/interactive.png",
  1332. selectedIconPath: '/static/pages/images/interactive_h.png',
  1333. pagePath: 'pages/interactive/index',
  1334. click: 'goInteractive',
  1335. channel: 'interactive',
  1336. index: 3,
  1337. show: true
  1338. },
  1339. {
  1340. text: "发现",
  1341. iconPath: "/static/pages/images/found.png",
  1342. selectedIconPath: '/static/pages/images/found_h.png',
  1343. pagePath: 'pages/found/found',
  1344. click: 'goFound',
  1345. channel: 'found',
  1346. index: 3,
  1347. show: true
  1348. },
  1349. {
  1350. text: "我的",
  1351. iconPath: '/static/pages/images/user.png',
  1352. selectedIconPath: '/static/pages/images/user_h.png',
  1353. pagePath: 'pages/user/user',
  1354. click: 'goUser',
  1355. channel: 'user',
  1356. index: 6,
  1357. show: true
  1358. }
  1359. ]
  1360. module.exports = {
  1361. setStorage: setStorage,
  1362. getStorage: getStorage,
  1363. postRequest: postRequest,
  1364. postRequestLoding: postRequestLoding,
  1365. getRequest: getRequest,
  1366. putRequest: putRequest,
  1367. putRequestJson: putRequestJson,
  1368. msg: msg,
  1369. g: g,
  1370. p: p,
  1371. env: env,
  1372. send: send,
  1373. redirectIndex: redirectIndex,
  1374. saveImage: saveImage,
  1375. saveImageToPhotosAlbum: saveImageToPhotosAlbum,
  1376. uploadFile: uploadFile,
  1377. msgConfirm: msgConfirm,
  1378. getConfig: getConfig,
  1379. load: load,
  1380. isLogin: isLogin,
  1381. isLogins: isLogins,
  1382. payOrder: payOrder,
  1383. payOrders: payOrders,
  1384. getLocation: getLocation,
  1385. scopeAddress: scopeAddress,
  1386. isAuth: isAuth,
  1387. alertMsg: alertMsg,
  1388. getToken: getToken,
  1389. loadIng: loadIng,
  1390. removeStorage: removeStorage,
  1391. public: publics,
  1392. header: header,
  1393. // gettmplIds: gettmplIds,
  1394. excludeSpecial: excludeSpecial,
  1395. tab: tab,
  1396. msgConfirmText: msgConfirmText,
  1397. silenceLogin: silenceLogin,
  1398. getWXUserProfile: getWXUserProfile,
  1399. updataWxInfos: updataWxInfos,
  1400. saveBehavior: saveBehavior,
  1401. getBehavior: getBehavior,
  1402. saveBehaviorNew:saveBehaviorNew,
  1403. unitConverter: unitConverter,
  1404. initIMChat: initIMChat,
  1405. getIMToken: getIMToken,
  1406. jumpConversation: jumpConversation,
  1407. jumpSingleChatRoom: jumpSingleChatRoom,
  1408. getsysConfig:getsysConfig
  1409. }