request.js 35 KB

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