request.js 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  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 keyc = 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(keyc)
  206. }
  207. }
  208. if(item.indexOf('rendered')>-1){
  209. let keyc = 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(keyc)
  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 keyc = 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 keyc = 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. success.call(this, data)
  1266. })
  1267. }
  1268. /**
  1269. * 跳入聊天
  1270. * @param {Object} userId 对方用户ID
  1271. * @param {Object} avatar 对方用户头像
  1272. * @param {Object} realName 对方用户名称
  1273. */
  1274. const jumpSingleChatRoom = function(userId, avatar, realName) {
  1275. var my = uni.getStorageSync("myUsername");
  1276. var nameList = {
  1277. myName: my,
  1278. your: 'rs_' + userId
  1279. };
  1280. uni.setStorage({
  1281. key: 'imUserInfo_' + nameList.your,
  1282. data: {
  1283. avatar: avatar,
  1284. id: userId,
  1285. nickName: realName
  1286. }
  1287. });
  1288. uni.navigateTo({
  1289. url: "/chat/chatroom/chatroom?username=" + JSON.stringify(nameList)
  1290. });
  1291. }
  1292. /**
  1293. * text:展示导航名
  1294. * iconPath:未点击显示图标
  1295. * selectedIconPath:选中图标
  1296. * pagePath:页面路径
  1297. * channel:匹配名
  1298. * click:点击事件
  1299. * index:排序
  1300. * show:是否显示
  1301. */
  1302. var selectedIconPath
  1303. if (header.appId == 'ZQ1VK5oc17I387E') {
  1304. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'yunyao_h.png'
  1305. } else {
  1306. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'home_h.png'
  1307. }
  1308. var tab = [{
  1309. text: "首页",
  1310. iconPath: "/static/pages/images/home.png",
  1311. selectedIconPath: '/static/pages/images/home_h.png',
  1312. pagePath: 'pages/index/index',
  1313. channel: 'home',
  1314. click: 'goHome',
  1315. index: 1,
  1316. show: true
  1317. },
  1318. {
  1319. text: "活动",
  1320. iconPath: "/static/pages/images/activity.png",
  1321. selectedIconPath: '/static/pages/images/activity_h.png',
  1322. pagePath: 'pages/matchList/index',
  1323. click: 'goMatch',
  1324. channel: 'match',
  1325. index: 2,
  1326. show: true
  1327. },
  1328. {
  1329. text: "社区",
  1330. iconPath: "/static/pages/images/interactive.png",
  1331. selectedIconPath: '/static/pages/images/interactive_h.png',
  1332. pagePath: 'pages/interactive/index',
  1333. click: 'goInteractive',
  1334. channel: 'interactive',
  1335. index: 3,
  1336. show: true
  1337. },
  1338. {
  1339. text: "发现",
  1340. iconPath: "/static/pages/images/found.png",
  1341. selectedIconPath: '/static/pages/images/found_h.png',
  1342. pagePath: 'pages/found/found',
  1343. click: 'goFound',
  1344. channel: 'found',
  1345. index: 3,
  1346. show: true
  1347. },
  1348. {
  1349. text: "我的",
  1350. iconPath: '/static/pages/images/user.png',
  1351. selectedIconPath: '/static/pages/images/user_h.png',
  1352. pagePath: 'pages/user/user',
  1353. click: 'goUser',
  1354. channel: 'user',
  1355. index: 6,
  1356. show: true
  1357. }
  1358. ]
  1359. module.exports = {
  1360. setStorage: setStorage,
  1361. getStorage: getStorage,
  1362. postRequest: postRequest,
  1363. postRequestLoding: postRequestLoding,
  1364. getRequest: getRequest,
  1365. putRequest: putRequest,
  1366. putRequestJson: putRequestJson,
  1367. msg: msg,
  1368. g: g,
  1369. p: p,
  1370. env: env,
  1371. send: send,
  1372. redirectIndex: redirectIndex,
  1373. saveImage: saveImage,
  1374. saveImageToPhotosAlbum: saveImageToPhotosAlbum,
  1375. uploadFile: uploadFile,
  1376. msgConfirm: msgConfirm,
  1377. getConfig: getConfig,
  1378. load: load,
  1379. isLogin: isLogin,
  1380. isLogins: isLogins,
  1381. payOrder: payOrder,
  1382. payOrders: payOrders,
  1383. getLocation: getLocation,
  1384. scopeAddress: scopeAddress,
  1385. isAuth: isAuth,
  1386. alertMsg: alertMsg,
  1387. getToken: getToken,
  1388. loadIng: loadIng,
  1389. removeStorage: removeStorage,
  1390. public: publics,
  1391. header: header,
  1392. // gettmplIds: gettmplIds,
  1393. excludeSpecial: excludeSpecial,
  1394. tab: tab,
  1395. msgConfirmText: msgConfirmText,
  1396. silenceLogin: silenceLogin,
  1397. getWXUserProfile: getWXUserProfile,
  1398. updataWxInfos: updataWxInfos,
  1399. saveBehavior: saveBehavior,
  1400. getBehavior: getBehavior,
  1401. saveBehaviorNew:saveBehaviorNew,
  1402. unitConverter: unitConverter,
  1403. initIMChat: initIMChat,
  1404. getIMToken: getIMToken,
  1405. jumpConversation: jumpConversation,
  1406. jumpSingleChatRoom: jumpSingleChatRoom,
  1407. getsysConfig:getsysConfig
  1408. }