request.js 35 KB

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