request.js 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457
  1. const app = getApp();
  2. const env = {
  3. NODE_ENV: 'prd',
  4. dev: {
  5. // apiUrl: 'https://apitest.tongyu99.com',
  6. apiUrl: 'https://apitest.zhiqiyun.com'
  7. },
  8. product: {
  9. apiUrl: 'https://api.tongyu99.com'
  10. },
  11. tongyu: {
  12. apiUrl: 'https://kkapi.tongyu99.com'
  13. },
  14. // 集和堂
  15. jihetang: {
  16. apiUrl: 'https://api.ysb.zhiqiyun.com'
  17. },
  18. prd: {
  19. apiUrl: 'https://apimall.zhiqiyun.com'
  20. },
  21. pota: {
  22. // apiUrl: 'http://192.168.110.98:8098'
  23. // apiUrl: 'http://192.168.110.180:8098' ,//f
  24. // apiUrl: 'http://192.168.110.182:8098' ,//z
  25. apiUrl: 'http://192.168.110.176:8098' //y
  26. // apiUrl: 'http://192.168.110.117:8098'//l
  27. // apiUrl: 'http://192.168.110.216:8098'
  28. }
  29. }
  30. var header = {
  31. 'content-type': 'application/x-www-form-urlencoded',
  32. // 'appId': 'ZQMN3wuNVXAUiCv', //奥工匠正式环境
  33. // 'appId': 'ZQc5K6QOarBKJP4', //奥工匠测试环境
  34. // 'appId': 'ZQLekhQIkRxXr1C', //力美田
  35. // 'appId': 'ZQOQ5tTJYT6SM5V', //广联嗨购-智企云、注意直播插件
  36. // 'appId': 'ZQHtZekB64Yafta', //广联嗨购-通御
  37. // 'appId': 'ZQYkWdRhL2kIAwB', //仁和大药房
  38. // 'appId': 'ZQEHw4S7Gcaa78i', //广州集和堂
  39. // 'appId': 'ZQ6XiKauuAoSyfS', //金药堂
  40. // 'appId': 'ZQRSPr4qnuXwDhh', //叮当德胜
  41. // 'appId': 'ZQa41Hu7FvZyyNS', //乡亲闪送
  42. // 'appId': 'ZQT6vNJf7Axoy3T', //舒健之家
  43. // 'appId': 'ZQ59ZJo4TNLwmJx', //晓琳优品
  44. // 'appId': 'ZQan9wBIpcv48uN', //博爱优品 //
  45. // 'appId': 'ZQ70mYvjoPD4DKt', //采芝灵
  46. // 'appId': 'ZQbLBtuI3UHBH7W', //河南新时尚
  47. // 切换成荣康需要去pages.json文件中pages将pages/index/index和pages/timelyDelivery/index位置互换,
  48. // 还需在tabBar中将pages/live/live直播页面注释 放开pages/timelyDelivery/index页面
  49. // 'appId': 'ZQ1VK5oc17I387E', //荣康
  50. // 'appId': 'ZQyhfB15fRD4oyZ',//春和祥(小详优选)
  51. // 'appId': 'ZQ0lLxSnxchdAWv',//四季康来
  52. // 'appId': 'ZQ0E8h3MkfniR7T',//康宁医药
  53. // 'appId': 'ZQYPXLwAjFsUauW',//通御优选
  54. // 'appId': 'ZQNTQcK0jjP6xu6',//百惠康
  55. // 'appId': 'ZQ0sZSrxva6KiMR', //通御体验
  56. // 'appId': 'ZQmSmCPZwDNOdg0',//九芝堂
  57. // 'appId': 'ZQdNLxle47GNK6E',//济民
  58. // 'appId': 'ZQV47ZfNRAcKDWn',//佐今明
  59. // 'appId': 'ZQHwYFoTQAKqQR5', //柚荚
  60. // 'appId': 'ZQTyfVuvX03FHPB', //焦娇美人西渡店
  61. // 'appId': 'ZQKadcCOddpJwkT',//利省家居
  62. // 'appId': 'ZQ7ViGD7S1aasT9', //柚荚YOUGA
  63. // 'appId': 'ZQOrNJoG127SrcW', //云助手
  64. // 'appId': 'ZQ9yuJK43epkCb9', //精戈MALL
  65. // 'appId': 'ZQVhiq0ueRaGNUg', //一源有品/艾康团
  66. 'appId': 'ZQgrcXgeIQ1oPSl', //享团
  67. // 'appId': 'ZQn1yRLLTlwTxlw', //清泉云
  68. // 'appId': 'ZQcWYTdcOPsM5vH', //哈哈一起零食
  69. // 'appId': 'ZQDd5ottiRqkw2n', //测试
  70. // 'appId': 'ZQkLZa6ytyXyi3B', //一度教育
  71. // 'appId': 'ZQWUN8wdYBFHX10', //享游敦煌
  72. // 'appId': 'ZQfa7C3fxB0X2Hg', //艾康团
  73. // 'appId': 'ZQcE7DsNhdymuX2', //绿色助农鼓云
  74. // 'appId': 'ZQqd7o72Q75wq1C', //齐育图书商城
  75. // 'appId': 'ZQFtuQbAnuIj7nC', //桦飞优选
  76. // 'appId': 'ZQVeqRWpfeVCYAq', //十二时辰
  77. // 'appId': 'ZQT6vNJf7Axoy3T', //舒健之家
  78. // 'appId': 'ZQ7Xyww1dCDVfP2', //宏润食品
  79. // 'appId': 'ZQ5TUrK1LrehKl8', //大隐生态
  80. }
  81. /**小程序配置 */
  82. const publics = {
  83. picUrls: 'https://zhiqiyun.oss-cn-hangzhou.aliyuncs.com/static/', //图片地址
  84. 'copyrighttitle': '智企云', //底部版权公司名称
  85. 'copyrighttel': '400-698-5980', //底部版权服务电话
  86. 'copyrightlogo': 'zhiqiyun', //底部版权 logo 文件名
  87. 'yaomeng': 'https://cfwz.yaomengwang.cn/hunan?enterpriseCode=hnty&orderId=', //药盟接口地址
  88. 'storemanagers': 'https://websmall.zhiqiyun.com?appId=', //saas门店管理地址(智企云所有)
  89. 'channel': '', //处方中间渠道号 SAAS系统为空
  90. 'is_customer_pick_up': false,
  91. // 奥工匠
  92. // 'mapLBSKEY': 'UW5BZ-MTX66-FCPSC-ET264-2UESO-FHBXW',
  93. // 'iconSrc': 'lblue/',
  94. // 'titleTopBgColor':'#1582F7',
  95. //小程序ID wx636585333198880d
  96. // 力美田
  97. // 'mapLBSKEY': 'VBSBZ-4LWLK-7E5JC-AY5R4-H2NP6-QYBPC',
  98. // 'iconSrc': 'hBlue/',
  99. // 'titleTopBgColor':'#66a3c3',//72a0b4
  100. //小程序ID wx0afb77bedadc1c22
  101. // 广联嗨购
  102. // 'mapLBSKEY': 'D4ZBZ-HDV6P-GEQDJ-V5Q5Y-3YPN7-OJBOS',
  103. // 'iconSrc': 'red/',
  104. // 'titleTopBgColor':'#cd0b01',//00923f、00a3ff、c70303
  105. //小程序ID wxe5a8d24e2ad87575
  106. // 仁和大药房=
  107. // 'mapLBSKEY': 'OONBZ-VZXKU-A7TV2-2LWRF-IKLSE-PSFKX',
  108. // 'iconSrc': 'red/',
  109. // 'titleTopBgColor':'#cd0b01',
  110. //小程序ID wx51aa31ccf71b221a
  111. //广州集和堂
  112. // 'mapLBSKEY': 'GGOBZ-NVE3W-XM4RG-RZ3R4-LUMH2-KGB7J',
  113. // 'iconSrc': 'red/',
  114. // 'titleTopBgColor':'#cd0b01',
  115. //小程序ID wxa453effc4de53ac2
  116. //金药堂
  117. // 'mapLBSKEY': '6XQBZ-OSFK2-LWIUD-CZ5ZO-S2V23-HJBBO',
  118. // 'iconSrc': 'orange/',
  119. // 'titleTopBgColor':'#ffbb00',
  120. // //小程序ID wxbb4bc21cf658d44d
  121. //叮当德胜
  122. // 'mapLBSKEY': '4SUBZ-KDL64-VM2UW-D3MGZ-RDANV-BPBTN',
  123. // 'iconSrc': 'red/',
  124. // 'titleTopBgColor':'#d00b14',
  125. // //小程序ID wx35586586dfc5ed27
  126. //乡亲闪送
  127. // 'mapLBSKEY': 'SG4BZ-LNUL4-ZM4U5-D3YVT-LB6NJ-A5FZV',
  128. // 'iconSrc': 'blue/',
  129. // 'titleTopBgColor':'#1796CB',
  130. //小程序ID wx5e68cd5e35b52ec3
  131. //舒健之家
  132. // 'mapLBSKEY': 'WA7BZ-64ALS-CZHOV-65W4F-57MTK-3FBWP',
  133. // 'mapLBSKEY': 'YYUBZ-CDME3-GTQ3A-34NVB-2DOPH-ROFZ4',
  134. // 'iconSrc': 'blue/',
  135. // 'titleTopBgColor': '#1796CB',
  136. //小程序ID wxb78faf888080863d
  137. //晓琳优品
  138. // 'mapLBSKEY': 'U3XBZ-3JTLW-3QYRO-OZUUT-TQJLK-VCFRF',
  139. // 'iconSrc': 'green/',
  140. // 'titleTopBgColor':'#00923f',
  141. // //小程序ID wx2228ff7ff3c18914
  142. //博爱优品
  143. // 'mapLBSKEY': '5BOBZ-CZC6V-IMUPM-USQNJ-TBTM5-J4BN7',
  144. // 'iconSrc': 'lightseagreen/',
  145. // 'titleTopBgColor':'#18AAA3',
  146. //小程序ID wxd3d88847ac4f3a77
  147. //采芝灵
  148. // 'mapLBSKEY': 'GQ5BZ-YUJL4-WN4UX-XKZSV-R6LCH-WVBSQ',
  149. // 'iconSrc': 'lightseagreen/',
  150. // 'titleTopBgColor':'#18AAA3',
  151. //小程序ID wxfbaa745f985e9516
  152. // 河南新时尚
  153. // 'mapLBSKEY': 'TYXBZ-RSNC6-SUFSK-ML6L7-TJC32-KDF5U',
  154. // 'iconSrc': 'orange/',
  155. // 'titleTopBgColor':'#fc5c25',
  156. //小程序ID wxa2910c5a579be98e
  157. // 河南新时尚新
  158. // 'mapLBSKEY': '4RVBZ-ORDL4-WKNU3-DU3AF-PE5CS-CQFNY',
  159. // 'iconSrc': 'blue/',
  160. // 'titleTopBgColor':'#0065AC',
  161. //小程序ID wx0d8aaea41f357f01
  162. // 春和祥
  163. // 'mapLBSKEY': '6FTBZ-N6RWW-ZDURM-R57AO-OK6QH-3XFWF',
  164. // 'iconSrc': 'red/',
  165. // 'titleTopBgColor':'#cd0b01',
  166. //小程序ID wx37ac89533b3239de
  167. //荣康
  168. // 'mapLBSKEY': 'NPTBZ-NHJWV-RHSP6-UD5CZ-DZJMH-4UFCY',
  169. // 'iconSrc': 'blue/',
  170. // 'titleTopBgColor': '#0065AC',
  171. //小程序ID wx25cf96bbe43242ad
  172. //四季康来
  173. // 'mapLBSKEY': 'MF5BZ-VRMWP-44HDQ-VALQ2-V2OR2-FSFVW',
  174. // 'iconSrc': 'blue/',
  175. // 'titleTopBgColor':'#0065AC',
  176. //小程序ID wx01650f3aa51361af
  177. // 康宁医药
  178. // 'mapLBSKEY': 'V2BBZ-OSVK6-YG5S2-MZCL2-7TFRT-MIF2WP',
  179. // 'iconSrc': 'green/',
  180. // 'titleTopBgColor':'#23AC3A',
  181. // 小程序ID wx0e8038f07fda6370
  182. // 'adGroupId': '1196269897935630343',//通御优选
  183. // 'mapLBSKEY': '4VYBZ-KHUK3-6HW34-3WARL-FSA5Q-D4BVL',
  184. // 'iconSrc': 'lightseagreen/',
  185. // 'titleTopBgColor':'#008457',
  186. //小程序ID wxae03e9c5b5fcb1fb
  187. //百惠康
  188. // 'mapLBSKEY': 'JUHBZ-KT43F-OZLJV-J42KS-ZZXO3-WDFPH', //新KEY
  189. // 'iconSrc': 'green/',
  190. // 'titleTopBgColor':'#00923f',
  191. //小程序ID wxec640e9e6dee99a9
  192. // 通御体验
  193. // 'mapLBSKEY': 'EHDBZ-WKOWK-MAEJA-AFDZ6-TRT75-2HFGP',
  194. // 'iconSrc': 'lightseagreen/',
  195. // 'titleTopBgColor': '#18AAA3',
  196. //小程序ID wxcbb16b5f84df483e
  197. // 九芝堂
  198. // 'mapLBSKEY': 'E6UBZ-JI6WX-6J44X-Z774E-MWZWK-TRBAM',
  199. // 'iconSrc': 'red/',
  200. // 'titleTopBgColor':'#cd0b01',
  201. //小程序ID wx21258194d46c2837
  202. // 济民
  203. // 'mapLBSKEY': '6Z6BZ-4FFRX-H2T4D-74TLV-GB2VO-QPBNX',
  204. // 'iconSrc': 'green/',
  205. // 'titleTopBgColor':'#00923f',
  206. //小程序ID wx86813a2fbde25177
  207. // 'adGroupId': '1196269897935630340',//佐今明
  208. // 'mapLBSKEY': '7UJBZ-RG7WP-ZKRDP-LW2UZ-JFG2E-XVFBO', //新KEY
  209. // 'iconSrc': 'blue/',
  210. // 'titleTopBgColor':'#0065AC',
  211. //小程序ID wx3bcfbcd294199cda
  212. // 'adGroupId': '1196269897935630338', //柚荚
  213. // 'mapLBSKEY': 'CTLBZ-HV5KP-2Z3DD-VFPJO-6HGOT-QBBDT',
  214. // 'iconSrc': 'orange/',
  215. // 'titleTopBgColor': '#fc5c25',
  216. //小程序ID wxd6be35d5cf3554e2
  217. //'myTopBgColor':'#c9136d',
  218. // 'adGroupId': '1196269897935630339',//焦娇美人西渡店
  219. // 'mapLBSKEY': 'XJ4BZ-X5OW6-XJ2ST-M4PAA-4I4RZ-T3BH7',
  220. // 'iconSrc': 'pink/',
  221. // 'titleTopBgColor':'#c9136d',
  222. //小程序ID wx1824dd234dbd9cd4
  223. // 'adGroupId': '1196269897935630348',//柚荚YOUGA
  224. // 'mapLBSKEY': 'JCQBZ-SZQKK-U56JV-AOEIP-KNS73-6SF4Q',
  225. // 'iconSrc': 'red/',
  226. // 'titleTopBgColor':'#cd0b01',
  227. //小程序ID wx145fb0289399d9d7
  228. // 'adGroupId': '1196269897935630346',//利省家居
  229. // 'mapLBSKEY': 'GVJBZ-JWAC6-XVMSG-E2NOL-VKUFO-3DBYS',
  230. // 'iconSrc': 'blue/',
  231. // 'titleTopBgColor':'#0065AC',
  232. //小程序ID wx97cf9850fd1e0d96
  233. // 'adGroupId': '1196269897935630352',//云助手
  234. // 'mapLBSKEY': 'RRQBZ-DKHWD-TMF45-HHHOV-ADLQZ-DEB7X',
  235. // 'iconSrc': 'lblue/',
  236. // 'titleTopBgColor':'#00a3ff',
  237. //小程序ID wx0ecc71add476037a
  238. // 'adGroupId': '1196269897935630357',//精戈MALL
  239. // 'mapLBSKEY': 'C53BZ-4HD66-P4RSQ-EGH4V-OGTF5-QVB2D',
  240. // 'iconSrc': 'red/',
  241. // 'titleTopBgColor':'#c30d23',
  242. //小程序ID wxf6806bd34099aca1
  243. // 'adGroupId': '1196269897935630357',//艾康团
  244. // 'mapLBSKEY': 'GXZBZ-Z4VE6-62QST-MD4VW-3PLET-FZFS5',
  245. // 'iconSrc': 'red/',
  246. // 'titleTopBgColor':'#cd0b01',
  247. //小程序ID wx0ee780805b7f89c6
  248. //秘钥2acf05cba68661cd6a74d029bf89aefb
  249. // 'adGroupId': '1196269897935630352', //享团-宜得了
  250. 'mapLBSKEY': 'YQZBZ-6LMC4-IGQUO-XE64O-4UJL6-YNB77',
  251. 'iconSrc': 'red/',
  252. 'titleTopBgColor': '#cd0b01',
  253. // 小程序ID wxe7bec198ecfe1162
  254. // 'adGroupId': '1196269897935630352',//清泉云购
  255. // 'mapLBSKEY': 'JYDBZ-4V2C5-BJTIU-Q5N3Q-55TA5-XNB2A',
  256. // 'iconSrc': 'red/',
  257. // 'titleTopBgColor':'#cd0b01',
  258. // 小程序ID wx33b41a76932836fa
  259. //哈哈一起零食
  260. // 'mapLBSKEY': 'PMXBZ-SDLKP-J2JDO-VTXQX-LAYEE-LJFMG',
  261. // 'iconSrc': 'red/',
  262. // 'titleTopBgColor':'#cd0b01',
  263. //小程序ID wx89a0cbd5a9a684d2
  264. //一度教育
  265. // 'mapLBSKEY': '6F6BZ-TNLKF-BNGJW-NZRO7-IHLCZ-XWFSX',
  266. // 'iconSrc': 'red/',
  267. // 'titleTopBgColor':'#cd0b01',
  268. //小程序ID wx727adf669dd4f0ec
  269. //享游敦煌
  270. // 'mapLBSKEY': 'ABXBZ-E4GCJ-NGJFD-KGHBJ-2HRK2-LRBTL',
  271. // 'iconSrc': 'gold/',
  272. // 'titleTopBgColor':'#d27a07',
  273. //小程序ID wx8090f2557f633d35
  274. //一源有品
  275. // 'mapLBSKEY': 'ICHBZ-7AWK6-CQRSZ-EQBDM-AVIDK-WNFE2',
  276. // 'iconSrc': 'red/',
  277. // 'titleTopBgColor':'#cd0b01',
  278. //小程序ID wx506847824713881c
  279. // 秘钥cf8b5009d6b4e6ffbb75befeecb9e522
  280. //绿色助农鼓云
  281. // 'mapLBSKEY': 'S5FBZ-QDGL3-G6733-33C6R-JOYB3-24FV5',
  282. // 'iconSrc': 'orange/',
  283. // 'titleTopBgColor':'#fc5c25',
  284. //小程序ID wx584d4802269eb4ff
  285. //齐育图书商城
  286. // 'mapLBSKEY': 'ZC4BZ-DFNC4-CFPUZ-DJ7MP-XA2CK-L7FGU',
  287. // 'iconSrc': 'orange/',
  288. // 'titleTopBgColor':'#FF7B00',
  289. //小程序ID wx295f7a721393b35b
  290. //桦飞优选
  291. // 'mapLBSKEY': '5H5BZ-IRRC3-EN633-YB7JJ-A4AIO-6JBRI',
  292. // 'iconSrc': 'green/',
  293. // 'titleTopBgColor':'#00923f',
  294. //小程序ID wx3977e474e1b3e01c
  295. //十二时辰
  296. // 'mapLBSKEY': 'BW4BZ-T4ZL3-TM73D-3BKGX-YMGPF-O5F7Y',
  297. // 'iconSrc': 'green/',
  298. // 'titleTopBgColor':'#00923f',
  299. // 'skinNotColor': true
  300. //小程序ID wx74438083f45c646a
  301. //宏润食品
  302. // 'mapLBSKEY': '6TKBZ-K3KCD-6PQ44-PP5IB-EJY23-ZRBAM',
  303. // 'iconSrc': 'lblue/',
  304. // 'titleTopBgColor':'#00a3ff',
  305. //小程序ID wxa6d0922207de7cc4
  306. //大隐生态
  307. // 'mapLBSKEY': 'VMLBZ-NR5KJ-DKHFH-KKNNN-RLJQK-UHFFQ',
  308. // 'iconSrc': 'lightseagreen/',
  309. // 'titleTopBgColor':'#2b968e',
  310. //小程序ID wx6337e58691994808
  311. }
  312. /*
  313. * 获取token
  314. */
  315. const getToken = (success) => {
  316. let token = getStorage('AUTH_TOKEN');
  317. if (token) {
  318. success.call(this, token);
  319. return false;
  320. } else {
  321. loadToken(data => {
  322. success.call(this, data);
  323. });
  324. }
  325. }
  326. const loadToken = (success) => {
  327. let that = this
  328. uni.request({
  329. url: env[env.NODE_ENV].apiUrl + '/api/access_token',
  330. data: {},
  331. method: 'get',
  332. header: header,
  333. success(json) {
  334. if (json.statusCode !== 200) return msg(json.data.message);
  335. if (json.data.code !== 0) return msg(json.data.msg)
  336. setStorage('AUTH_TOKEN', json.data.data);
  337. success.call(that, json.data.data);
  338. },
  339. fail() {
  340. msg('access_token 获取失败');
  341. }
  342. })
  343. }
  344. /**
  345. * 微信小程序静默授权登录
  346. * @param {*} parentId
  347. * @param {*} merchantId
  348. */
  349. const silenceLogin = (parentId, merchantId) => {
  350. // #ifdef MP-WEIXIN
  351. if (!isLogins(false)) { //未登录
  352. uni.login({
  353. success(res) {
  354. console.log('静默授权登录>>>', res);
  355. let params = {
  356. code: res.code,
  357. parentId: parentId ? parentId : '',
  358. merchantId: merchantId ? merchantId : ''
  359. }
  360. return new Promise((resolve, reject) => {
  361. postRequest('/api/v3/silence/login', params, data => {
  362. if(data.token) setStorage('AUTH_TOKEN',data.token);
  363. getRequest('/api/user/my', {}, suc => {
  364. data.isDistriUser = suc.isDistriUser;
  365. setStorage('userInfo', data);
  366. });
  367. resolve();
  368. });
  369. })
  370. }
  371. });
  372. }
  373. // #endif
  374. }
  375. const getWXUserProfile = (suc) => {
  376. let that = this;
  377. var sessionKey = '';
  378. var openid = '';
  379. getApp().globalData.getCheckSessoin(json => {
  380. sessionKey = json.session_key;
  381. openid = json.openid;
  382. });
  383. try {
  384. uni.getUserProfile({
  385. desc: '完善信息',
  386. success: res => {
  387. updataWxInfos(res.iv, res.encryptedData, sessionKey, openid, suc);
  388. },
  389. fail: res => {
  390. console.log('授权失败数据>>>', res);
  391. msg(res);
  392. }
  393. });
  394. } catch (e) {
  395. // 老版
  396. wx.getUserInfo({
  397. success: function(ress) {
  398. updataWxInfos(res.iv, res.encryptedData, sessionKey, openid, suc);
  399. }
  400. });
  401. }
  402. }
  403. /**
  404. * 保存微信头像
  405. */
  406. const updataWxInfos = (iv, encryptedData, sessionKey, openid, suc) => {
  407. if (!encryptedData || !iv) return false;
  408. let _params = {
  409. sessionKey: sessionKey,
  410. openId: openid,
  411. iv: iv,
  412. encryptedData: encryptedData
  413. };
  414. postRequest('/api/user/weixin/update', _params, json => {
  415. setStorage('userInfo', json);
  416. suc.call();
  417. });
  418. }
  419. const clearValueEmpty = (data) => {
  420. let keyValue = {};
  421. for (let key in data) {
  422. let value = typeof data[key];
  423. if (value == 'string' && value) {
  424. if (data[key] != 'undefined' && data[key] != " " && data[key] != undefined && data[key] != null) {
  425. keyValue[key] = data[key];
  426. }
  427. // keyValue[key] = data[key];
  428. } else if (value == 'number' && value != null) {
  429. keyValue[key] = data[key];
  430. } else if (value == 'boolean') {
  431. keyValue[key] = data[key];
  432. } else {
  433. if (data[key]) keyValue[key] = data[key];
  434. }
  435. }
  436. return keyValue;
  437. }
  438. /**
  439. * 公共请求
  440. *
  441. * @param {*} url 请求url
  442. * @param {*} data 请求参数
  443. * @param {*} method 请求方法
  444. * @param {*} success 成功函数
  445. * @param {*} isLoad 是否显示加载提示
  446. */
  447. const baseRequest = (url, data, method, success, isLoad) => {
  448. getToken(token => {
  449. if (!isLoad) uni.showNavigationBarLoading();
  450. header.authorityToken = token;
  451. if (url.indexOf('/v3') != -1 || url.indexOf('/paper/create') != -1) {
  452. header['content-type'] = 'application/json;charset=UTF-8'
  453. } else {
  454. header['content-type'] = 'application/x-www-form-urlencoded'
  455. }
  456. uni.request({
  457. url: env[env.NODE_ENV].apiUrl + url,
  458. data: clearValueEmpty(data),
  459. method: method,
  460. header: header,
  461. success(json) {
  462. if (!isLoad) uni.hideNavigationBarLoading();
  463. if (json.statusCode !== 200) return msg(json.data.message);
  464. if (json.data.code === 10021 || json.data.code === 10020) {
  465. // console.log("第二次执行")
  466. removeStorage('AUTH_TOKEN');
  467. return redirectIndex();
  468. }
  469. if (json.data.code !== 0) {
  470. return msg(json.data.msg)
  471. }
  472. // console.log("第二次执行")
  473. let data = json.data.data;
  474. if (typeof data === 'string' && data.indexOf("{") === 0) {
  475. data = JSON.parse(data);
  476. }
  477. success.call(this, data);
  478. },
  479. fail() {
  480. if (!isLoad) uni.hideNavigationBarLoading();
  481. },
  482. // complete(){
  483. // success.call(this, data);
  484. // },
  485. })
  486. })
  487. }
  488. const loadIng = (msg) => {
  489. uni.showLoading({
  490. title: msg,
  491. mask: true
  492. })
  493. }
  494. /**POST请求 */
  495. const postRequest = (url, data, success, isLoad) => {
  496. header['content-type'] = 'application/x-www-form-urlencoded'
  497. baseRequest(url, data, 'post', success, isLoad);
  498. }
  499. const postRequestLoding = (url, data, success, isLoding) => {
  500. header['content-type'] = 'application/x-www-form-urlencoded'
  501. baseRequest(url, data, 'post', success, false, isLoding);
  502. }
  503. /**GET请求 */
  504. const getRequest = (url, data, success, isLoad) => {
  505. header['content-type'] = 'application/x-www-form-urlencoded'
  506. baseRequest(url, data, 'get', success, isLoad);
  507. }
  508. /**Put请求 */
  509. const putRequest = (url, data, success, isLoad) => {
  510. header['content-type'] = 'application/x-www-form-urlencoded'
  511. baseRequest(url, data, 'put', success, isLoad)
  512. }
  513. const putRequestJson = (url, data, success, isLoad) => {
  514. header['content-type'] = 'application/json;charset=UTF-8'
  515. baseRequest(url, data, 'put', success, isLoad)
  516. }
  517. /**
  518. * 上传文件
  519. * @param {*} url 请求url
  520. * @param {*} data 携带数据
  521. * @param {*} success 请求成功函数
  522. */
  523. const uploadFile = (url, data, success) => {
  524. // console.log(env[env.NODE_ENV].apiUrl + url, data)
  525. getToken(token => {
  526. uni.uploadFile({
  527. url: env[env.NODE_ENV].apiUrl + url,
  528. filePath: data,
  529. name: 'file',
  530. header: {
  531. 'appId': header['appId'],
  532. 'authorityToken': token
  533. },
  534. success(res) {
  535. if (res.statusCode !== 200) return msg('文件上传失败');
  536. let data = JSON.parse(res.data);
  537. if (data.code !== 0) return msg(data.msg);
  538. success.call(this, data.data);
  539. },
  540. })
  541. })
  542. }
  543. /**弹窗 */
  544. const msg = (title, success) => {
  545. if (title) {
  546. uni.showToast({
  547. title: title,
  548. icon: 'none',
  549. success() {
  550. if (success) success.call(this);
  551. }
  552. });
  553. }
  554. return false;
  555. }
  556. const msgConfirm = (msg, success, cancel) => {
  557. uni.showModal({
  558. title: '提示',
  559. content: msg,
  560. success(res) {
  561. if (res.confirm) {
  562. success.call(this);
  563. } else {
  564. if (cancel) cancel.call(this);
  565. }
  566. }
  567. })
  568. }
  569. const msgConfirmText = (msg, confirmText, success, cancel) => {
  570. uni.showModal({
  571. title: '提示',
  572. content: msg,
  573. confirmText: confirmText,
  574. success(res) {
  575. if (res.confirm) {
  576. success.call(this);
  577. } else {
  578. if (cancel) cancel.call(this);
  579. }
  580. }
  581. })
  582. }
  583. const alertMsg = (msg, success) => {
  584. uni.showModal({
  585. title: '提示',
  586. content: msg,
  587. showCancel: false,
  588. success(res) {
  589. if (success) success.call(this);
  590. }
  591. })
  592. return false;
  593. }
  594. const load = msg => {
  595. uni.showLoading({
  596. title: msg,
  597. mask: true
  598. })
  599. }
  600. const g = (url, success, isLoad) => {
  601. getRequest(url, {}, success, isLoad)
  602. }
  603. const p = (url, success, isLoad) => {
  604. postRequest(url, {}, success, isLoad)
  605. }
  606. const send = (url, mobile, success, error) => {
  607. if (!mobile) {
  608. return msg('手机号码不能为空', error);
  609. }
  610. postRequest(url, {
  611. phone: mobile
  612. }, json => {
  613. if (json.code !== 0) {
  614. return msg(json.msg, error);
  615. }
  616. let time = 60;
  617. const initTime = setInterval(() => {
  618. time--;
  619. if (time > 0) {
  620. success.call(this, time + '秒后获取');
  621. } else {
  622. clearInterval(initTime);
  623. success.call(this, '获取验证码');
  624. }
  625. }, 1000)
  626. })
  627. }
  628. // 登陆拦截
  629. const redirectIndex = (params) => {
  630. // uni.clearStorageSync();
  631. // console.log(params)
  632. var pages = getCurrentPages();
  633. // console.log("pages》》》》》登陆拦截", pages);
  634. let currentUrl;
  635. if (pages) {
  636. var currentPage = pages[pages.length - 1];
  637. if (currentPage) {
  638. currentUrl = currentPage.route;
  639. let query = currentPage.data.query;
  640. if (query) {
  641. for (let key in query) {
  642. const fo = key + '=' + query[key];
  643. currentUrl += currentUrl.indexOf('?') > -1 ? '&' + fo : '?' + fo;
  644. }
  645. }
  646. if (currentUrl) {
  647. console.log('currentUrl》》》》》', currentUrl);
  648. setStorage("REDIRECT_URL", '/' + currentUrl)
  649. if (currentUrl == 'pages/authorize/authorize') {
  650. console.log('当前已经处于登录页面,不在向下执行跳转');
  651. return
  652. }
  653. }
  654. }
  655. }
  656. let redirectUrl = '/pages/authorize/authorize' + (params ? params : '');
  657. // console.log("登陆拦截")
  658. uni.navigateTo({
  659. url: redirectUrl
  660. })
  661. return false;
  662. }
  663. const saveImage = (url) => {
  664. uni.saveImageToPhotosAlbum({
  665. filePath: url,
  666. success() {
  667. msg('图片保存成功');
  668. }
  669. })
  670. }
  671. const saveImageToPhotosAlbum = (url) => {
  672. if (!url) return msg('小程序码不存在');
  673. uni.getImageInfo({
  674. src: url,
  675. success(json) {
  676. // uni.getSetting({
  677. // success(res) {
  678. // if (!res.authSetting['scope.writePhotosAlbum']) {
  679. // uni.authorize({
  680. // scope: 'scope.writePhotosAlbum',
  681. // success() {
  682. // saveImage(json.path);
  683. // }
  684. // })
  685. // } else {
  686. // saveImage(json.path);
  687. // }
  688. // }
  689. // })
  690. }
  691. })
  692. }
  693. const getConfig = (config, id) => {
  694. let con = {};
  695. config.info.forEach(inf => {
  696. // console.log(inf.version, inf.version ? inf.version.indexOf(id) : '-')
  697. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  698. con[inf.setName] = inf.setDefault;
  699. });
  700. config.card.forEach(inf => {
  701. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  702. con[inf.setName] = inf.setDefault;
  703. });
  704. config.realTime.forEach(inf => {
  705. if (inf.isSet && (!inf.version || inf.version.indexOf(id) > -1))
  706. con[inf.setName] = inf.setDefault;
  707. });
  708. return con;
  709. }
  710. const isLogin = async (error) => {
  711. let userInfo = getStorage('userInfo');
  712. if (!userInfo || !userInfo.id) {
  713. if (error) return false;
  714. // console.log("第一次执行")
  715. return redirectIndex();
  716. }
  717. return true;
  718. }
  719. //检测是否登录
  720. const isLogins = (isGoLogin) => {
  721. let userInfo = getStorage('userInfo');
  722. if (!userInfo) {
  723. if (isGoLogin) {
  724. redirectIndex();
  725. }
  726. return false;
  727. }
  728. return true;
  729. }
  730. const setStorage = (key, value) => {
  731. uni.setStorageSync(env.NODE_ENV + "_" + key, value)
  732. }
  733. const getStorage = (key) => {
  734. return uni.getStorageSync(env.NODE_ENV + "_" + key)
  735. }
  736. const removeStorage = (key) => {
  737. return uni.removeStorageSync(env.NODE_ENV + "_" + key);
  738. }
  739. /**
  740. * 缓存模板id
  741. */
  742. // const gettmplIds = () => {
  743. // getRequest('/api/wxmes/querylist', {}, res => {
  744. // setStorage('tmplIds', res)
  745. // console.log(res)
  746. // })
  747. // }
  748. //微信支付订单公共方法
  749. const payOrder = (id,success) => {
  750. var loctionAddressMap = getStorage('loctionAddressMap');
  751. var datas = {
  752. id: id
  753. };
  754. if (loctionAddressMap) {
  755. datas.province = loctionAddressMap.province;
  756. datas.city = loctionAddressMap.city;
  757. };
  758. if(getStorage('isVideoScene')){
  759. uni.checkBeforeAddOrder({
  760. success (res){
  761. console.log('下单前置检查',res)
  762. let data = res.data;
  763. data.requiredFundType = 0;
  764. datas.sceneCheckStr = JSON.stringify(data);
  765. wexinPay(datas,success)
  766. },
  767. })
  768. }else{
  769. wexinPay(datas,success)
  770. }
  771. }
  772. //支付中或已支付
  773. const payStatus = (json, id, success) =>{
  774. if(json&&json.code === 115){
  775. setTimeout(res=>{
  776. uni.hideLoading();
  777. isShowLoading = false;
  778. uni.showModal({
  779. title: '提示',
  780. content: '当前订单正在支付或30秒后重试',
  781. confirmText: '我知道了',
  782. showCancel: false,
  783. success(res) {
  784. }
  785. })
  786. },3000)
  787. return false;
  788. }
  789. if (json.type === 2 || json.type === 3) {
  790. //调用后台判断订单是否支付成功
  791. let i = 0;
  792. let timer = setInterval(() => {
  793. postRequest('/api/order/check', {
  794. id: id
  795. }, res => {
  796. if (res.isSuccess || i === 4) {
  797. clearInterval(timer);
  798. success.call(this, res.isSuccess);
  799. } else {
  800. i++;
  801. }
  802. }, true)
  803. }, 200);
  804. // success.call(this);
  805. return false;
  806. }
  807. }
  808. // 支付成功回调
  809. const paySuccess = (id,success) =>{
  810. console.log('支付成功')
  811. let i = 0;
  812. let timer = setInterval(() => {
  813. postRequest('/api/order/check', {
  814. id: id
  815. }, res => {
  816. console.log(i)
  817. if (res.isSuccess || i === 5) {
  818. clearInterval(timer);
  819. success.call(this, res.isSuccess);
  820. } else {
  821. i++;
  822. }
  823. }, true)
  824. }, 500);
  825. }
  826. // 支付失败回调
  827. const payFail = (id) =>{
  828. console.log('支付失败')
  829. postRequest('/api/order/cancelPay', {
  830. id: id
  831. }, data => {
  832. uni.redirectTo({
  833. url: '/mine/orderDet/orderDet?id=' + id,
  834. })
  835. })
  836. }
  837. const wexinPay = (datas, success) => {
  838. let isShowLoading = false;
  839. if (!isShowLoading) {
  840. loadIng('加载中');
  841. // console.log('加载中')
  842. isShowLoading = true;
  843. }
  844. // #ifdef MP-WEIXIN
  845. postRequest('/api/order/weixin/pay', datas, json => {
  846. // console.log('json',json)
  847. payStatus(json, datas.id, success)
  848. const sceneCheckStr = datas.sceneCheckStr;
  849. if(sceneCheckStr && JSON.parse(sceneCheckStr).requiredFundType === 1){
  850. console.log('拉起收银台')
  851. wx.requestOrderPayment({
  852. timeStamp: json.timeStamp,
  853. nonceStr: json.nonceStr,
  854. package: json.packages,
  855. signType: json.signType,
  856. orderInfo: json.orderInfo,
  857. paySign: json.sign,
  858. success: function() {
  859. paySuccess(datas.id,success)
  860. },
  861. fail: function(res) {
  862. console.log(res);
  863. payFail(datas.id)
  864. }
  865. })
  866. }else{
  867. uni.requestPayment({
  868. timeStamp: json.timeStamp,
  869. nonceStr: json.nonceStr,
  870. package: json.packages,
  871. signType: json.signType,
  872. paySign: json.sign,
  873. success: function() {
  874. paySuccess(datas.id,success)
  875. },
  876. fail: function(res) {
  877. console.log(res);
  878. payFail(datas.id)
  879. }
  880. })
  881. }
  882. if (isShowLoading) {
  883. uni.hideLoading();
  884. isShowLoading = false;
  885. }
  886. })
  887. // #endif
  888. // #ifdef MP-ALIPAY
  889. datas.payChannel = 'alipay_lite ';
  890. postRequest('/api/order/weixin/pay', datas, json => {
  891. // console.log(json)
  892. if (json.type === 2 || json.type === 3) {
  893. //调用后台判断订单是否支付成功
  894. let i = 0;
  895. let timer = setInterval(() => {
  896. postRequest('/api/order/check', {
  897. id: id
  898. }, res => {
  899. if (res.isSuccess || i === 4) {
  900. clearInterval(timer);
  901. success.call(this, res.isSuccess);
  902. } else {
  903. i++;
  904. }
  905. }, true)
  906. }, 200);
  907. // success.call(this);
  908. return false;
  909. }
  910. uni.requestPayment({
  911. provider: 'alipay',
  912. orderInfo: json.packages,
  913. success: function() {
  914. paySuccess(datas.id,success)
  915. },
  916. fail: function(res) {
  917. payFail(datas.id)
  918. console.log(res);
  919. }
  920. })
  921. if (isShowLoading) {
  922. uni.hideLoading();
  923. isShowLoading = false;
  924. }
  925. })
  926. // #endif
  927. }
  928. //微信支付订单公共方法
  929. const payOrdersss = (id, success) => {
  930. let isShowLoading = false;
  931. if (!isShowLoading) {
  932. loadIng('加载中');
  933. // console.log('加载中')
  934. isShowLoading = true;
  935. }
  936. var loctionAddressMap = getStorage('loctionAddressMap');
  937. var datas = {
  938. id: id
  939. };
  940. if (loctionAddressMap) {
  941. datas.province = loctionAddressMap.province;
  942. datas.city = loctionAddressMap.city;
  943. };
  944. // #ifdef MP-WEIXIN
  945. postRequest('/api/order/weixin/pay', datas, json => {
  946. // console.log(json)
  947. if (json.type === 2 || json.type === 3) {
  948. //调用后台判断订单是否支付成功
  949. let i = 0;
  950. let timer = setInterval(() => {
  951. postRequest('/api/order/check', {
  952. id: id
  953. }, res => {
  954. if (res.isSuccess || i === 4) {
  955. clearInterval(timer);
  956. success.call(this, res.isSuccess);
  957. } else {
  958. i++;
  959. }
  960. }, true)
  961. }, 200);
  962. // success.call(this);
  963. return false;
  964. }
  965. uni.requestPayment({
  966. timeStamp: json.timeStamp,
  967. nonceStr: json.nonceStr,
  968. package: json.packages,
  969. signType: json.signType,
  970. paySign: json.sign,
  971. success: function() {
  972. console.log('支付成功')
  973. let i = 0;
  974. let timer = setInterval(() => {
  975. postRequest('/api/order/check', {
  976. id: id
  977. }, res => {
  978. console.log(i)
  979. if (res.isSuccess || i === 5) {
  980. clearInterval(timer);
  981. success.call(this, res.isSuccess);
  982. } else {
  983. i++;
  984. }
  985. }, true)
  986. }, 500);
  987. },
  988. fail: function(res) {
  989. console.log('支付失败')
  990. postRequest('/api/order/cancelPay', {
  991. id: id
  992. }, data => {
  993. uni.redirectTo({
  994. url: '/mine/orderDet/orderDet?id=' + id,
  995. })
  996. })
  997. console.log(res);
  998. }
  999. })
  1000. if (isShowLoading) {
  1001. uni.hideLoading();
  1002. isShowLoading = false;
  1003. }
  1004. })
  1005. // #endif
  1006. // #ifdef MP-ALIPAY
  1007. datas.payChannel = 'alipay_lite ';
  1008. postRequest('/api/order/weixin/pay', datas, json => {
  1009. // console.log(json)
  1010. if (json.type === 2 || json.type === 3) {
  1011. //调用后台判断订单是否支付成功
  1012. let i = 0;
  1013. let timer = setInterval(() => {
  1014. postRequest('/api/order/check', {
  1015. id: id
  1016. }, res => {
  1017. if (res.isSuccess || i === 4) {
  1018. clearInterval(timer);
  1019. success.call(this, res.isSuccess);
  1020. } else {
  1021. i++;
  1022. }
  1023. }, true)
  1024. }, 200);
  1025. // success.call(this);
  1026. return false;
  1027. }
  1028. uni.requestPayment({
  1029. provider: 'alipay',
  1030. orderInfo: json.packages,
  1031. success: function() {
  1032. console.log('支付成功')
  1033. let i = 0;
  1034. let timer = setInterval(() => {
  1035. postRequest('/api/order/check', {
  1036. id: id
  1037. }, res => {
  1038. console.log(i)
  1039. if (res.isSuccess || i === 5) {
  1040. clearInterval(timer);
  1041. success.call(this, res.isSuccess);
  1042. } else {
  1043. i++;
  1044. }
  1045. }, true)
  1046. }, 500);
  1047. },
  1048. fail: function(res) {
  1049. console.log('支付失败')
  1050. postRequest('/api/order/cancelPay', {
  1051. id: id
  1052. }, data => {
  1053. uni.redirectTo({
  1054. url: '/mine/orderDet/orderDet?id=' + id,
  1055. })
  1056. })
  1057. console.log(res);
  1058. }
  1059. })
  1060. if (isShowLoading) {
  1061. uni.hideLoading();
  1062. isShowLoading = false;
  1063. }
  1064. })
  1065. // #endif
  1066. }
  1067. //微信支付订单公共方法 ==活动
  1068. const payOrders = (id, success, type) => {
  1069. let isShowLoading = false;
  1070. if (!isShowLoading) {
  1071. loadIng('加载中');
  1072. // console.log('加载中')
  1073. isShowLoading = true;
  1074. }
  1075. postRequest('/api/order/weixin/pay', {
  1076. id: id
  1077. }, json => {
  1078. // console.log(json)
  1079. payStatus(json, id, success)
  1080. uni.requestPayment({
  1081. timeStamp: json.timeStamp,
  1082. nonceStr: json.nonceStr,
  1083. package: json.packages,
  1084. signType: json.signType,
  1085. paySign: json.sign,
  1086. success: function() {
  1087. paySuccess(id, success)
  1088. },
  1089. fail: function(res) {
  1090. console.log('支付失败')
  1091. postRequest('/api/order/cancelPay', {
  1092. id: id
  1093. }, data => {
  1094. uni.redirectTo({
  1095. url: '/mine/activity/activity',
  1096. })
  1097. })
  1098. console.log(res);
  1099. }
  1100. })
  1101. if (isShowLoading) {
  1102. uni.hideLoading();
  1103. isShowLoading = false;
  1104. }
  1105. })
  1106. }
  1107. const authSetting = (authority, success, error) => {
  1108. // console.log(authority,success)
  1109. // #ifndef H5
  1110. uni.getSetting({
  1111. success(res) {
  1112. if (res.authSetting[authority]) {
  1113. success.call(this);
  1114. return false;
  1115. }
  1116. uni.authorize({
  1117. scope: authority,
  1118. success() {
  1119. success.call(this);
  1120. },
  1121. fail: function(res) {
  1122. error.call(this);
  1123. }
  1124. })
  1125. }
  1126. })
  1127. // #endif
  1128. }
  1129. const getLocation = (suss) => {
  1130. // #ifdef MP-WEIXIN
  1131. authSetting('scope.userLocation', () => {
  1132. // load('定位中…');
  1133. uni.getLocation({
  1134. type: 'gcj02',
  1135. // isHighAccuracy: true,
  1136. success: function(res) {
  1137. // uni.hideLoading();
  1138. console.log(res, "789")
  1139. suss.call(this, res);
  1140. },
  1141. fail: function(res) {
  1142. console.log("调用失败", res)
  1143. suss.call(this, 2)
  1144. // uni.hideLoading();
  1145. }
  1146. })
  1147. }, () => {
  1148. // uni.hideLoading();
  1149. console.log("取消")
  1150. suss.call(this, 1)
  1151. });
  1152. // #endif
  1153. // #ifdef MP-ALIPAY
  1154. uni.getLocation({
  1155. type: 'gcj02',
  1156. // isHighAccuracy: true,
  1157. success: function(res) {
  1158. // uni.hideLoading();
  1159. console.log(res, "789")
  1160. suss.call(this, res);
  1161. },
  1162. fail: function(res) {
  1163. console.log("调用失败", res)
  1164. suss.call(this, 2)
  1165. // uni.hideLoading();
  1166. }
  1167. })
  1168. // #endif
  1169. // #ifdef H5
  1170. uni.getLocation({
  1171. type: 'gcj02',
  1172. isHighAccuracy: true,
  1173. success: function(res) {
  1174. // uni.hideLoading();
  1175. console.log(res)
  1176. suss.call(this, res, "789");
  1177. },
  1178. fail: function() {
  1179. console.log("调用失败", res)
  1180. suss.call(this, 2)
  1181. // uni.hideLoading();
  1182. }
  1183. })
  1184. // #endif
  1185. }
  1186. const scopeAddress = (success) => {
  1187. // #ifdef MP-WEIXIN
  1188. authSetting('scope.address', () => {
  1189. uni.chooseAddress({
  1190. success: function(res) {
  1191. success.call(this, res);
  1192. },
  1193. })
  1194. }, () => {
  1195. msg('未设置开放权限')
  1196. });
  1197. // #endif
  1198. // #ifdef MP-ALIPAY
  1199. uni.chooseAddress({
  1200. success: function(res) {
  1201. success.call(this, res);
  1202. },
  1203. })
  1204. // #endif
  1205. }
  1206. const isAuth = () => {
  1207. const user = getStorage('userInfo');
  1208. return user && user.id;
  1209. }
  1210. // 去掉字符串中的特殊字符和转义字符
  1211. const excludeSpecial = (s) => {
  1212. // 去掉转义字符
  1213. // s = s.replace(/[\'\"\\\/\b\f\n\r\t]/g, '');
  1214. const pattern = /[`~!@#$^&*()=|{}':;',\\\[\]\.<>\/?~!@#¥……&*()——|{}【】';:""' + - - _ % 。,、?\s]/g;
  1215. if (s != undefined || s != null) {
  1216. s = s.replace(pattern, "")
  1217. }
  1218. return s;
  1219. }
  1220. // 行为操作
  1221. const saveBehavior = (params, success) => {
  1222. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1223. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1224. postRequest('/api/v3/save', params, data => {
  1225. success.call(this, data)
  1226. })
  1227. }
  1228. const getBehavior = (params, success) => {
  1229. //用户行为:behavior 1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、海报
  1230. //用户行为操作对象:type 1、产品 2、赛事 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 11、用户 12、用户须知 13、素材 15、科室 16、海报 20、医生 21日历、探索 47评价
  1231. console.log('行为')
  1232. getRequest('/api/v3/get', params, data => {
  1233. success.call(this, data)
  1234. })
  1235. }
  1236. /**
  1237. * text:展示导航名
  1238. * iconPath:未点击显示图标
  1239. * selectedIconPath:选中图标
  1240. * pagePath:页面路径
  1241. * channel:匹配名
  1242. * click:点击事件
  1243. * index:排序
  1244. * show:是否显示
  1245. */
  1246. var selectedIconPath
  1247. if (header.appId == 'ZQ1VK5oc17I387E') {
  1248. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'yunyao_h.png'
  1249. } else {
  1250. selectedIconPath = '/static/pages/images/' + publics.iconSrc + 'home_h.png'
  1251. }
  1252. var tab = [{
  1253. text: header.appId == 'ZQ1VK5oc17I387E' ? '云药房' : "首页",
  1254. iconPath: header.appId == 'ZQ1VK5oc17I387E' ? '/static/pages/images/yunyao.png' :
  1255. "/static/pages/images/home.png",
  1256. selectedIconPath: selectedIconPath,
  1257. pagePath: 'pages/index/index',
  1258. channel: 'home',
  1259. click: 'goHome',
  1260. index: header.appId == 'ZQ1VK5oc17I387E' ? 3 : 1,
  1261. show: true
  1262. },
  1263. {
  1264. text: "分类",
  1265. iconPath: "/static/pages/images/sort.png",
  1266. selectedIconPath: '/static/pages/images/' + publics.iconSrc + 'sort_h.png',
  1267. pagePath: 'pages/sort/sort',
  1268. click: 'goSort',
  1269. channel: 'sort',
  1270. index: 2,
  1271. show: true
  1272. },
  1273. {
  1274. text: "社区",
  1275. iconPath: "/static/pages/images/interactive.png",
  1276. selectedIconPath: '/static/pages/images/' + publics.iconSrc + 'interactive_h.png',
  1277. pagePath: 'pages/interactive/index',
  1278. click: 'goInteractive',
  1279. channel: 'interactive',
  1280. index: 3,
  1281. show: true
  1282. },
  1283. {
  1284. text: "直播",
  1285. iconPath: "/static/pages/images/live.png",
  1286. selectedIconPath: '/static/pages/images/' + publics.iconSrc + 'live_h.png',
  1287. pagePath: 'pages/live/live',
  1288. click: 'goLive',
  1289. channel: 'live',
  1290. index: 3,
  1291. show: header.appId == 'ZQ1VK5oc17I387E' ? false : false
  1292. },
  1293. {
  1294. text: "购物车",
  1295. iconPath: '/static/pages/images/cart.png',
  1296. selectedIconPath: '/static/pages/images/' + publics.iconSrc + 'cart_h.png',
  1297. pagePath: 'pages/cart/cart',
  1298. click: 'goCart',
  1299. channel: 'cart',
  1300. index: 5,
  1301. show: true
  1302. },
  1303. {
  1304. text: "我的",
  1305. iconPath: '/static/pages/images/user.png',
  1306. selectedIconPath: '/static/pages/images/' + publics.iconSrc + 'user_h.png',
  1307. pagePath: 'pages/user/user',
  1308. click: 'goUser',
  1309. channel: 'user',
  1310. index: 6,
  1311. show: true
  1312. }
  1313. ]
  1314. module.exports = {
  1315. setStorage: setStorage,
  1316. getStorage: getStorage,
  1317. postRequest: postRequest,
  1318. postRequestLoding: postRequestLoding,
  1319. getRequest: getRequest,
  1320. putRequest: putRequest,
  1321. putRequestJson: putRequestJson,
  1322. msg: msg,
  1323. g: g,
  1324. p: p,
  1325. env: env,
  1326. send: send,
  1327. redirectIndex: redirectIndex,
  1328. saveImage: saveImage,
  1329. saveImageToPhotosAlbum: saveImageToPhotosAlbum,
  1330. uploadFile: uploadFile,
  1331. msgConfirm: msgConfirm,
  1332. getConfig: getConfig,
  1333. load: load,
  1334. isLogin: isLogin,
  1335. isLogins: isLogins,
  1336. payOrder: payOrder,
  1337. payOrders: payOrders,
  1338. getLocation: getLocation,
  1339. scopeAddress: scopeAddress,
  1340. isAuth: isAuth,
  1341. alertMsg: alertMsg,
  1342. getToken: getToken,
  1343. loadIng: loadIng,
  1344. removeStorage: removeStorage,
  1345. public: publics,
  1346. header: header,
  1347. // gettmplIds: gettmplIds,
  1348. excludeSpecial: excludeSpecial,
  1349. tab: tab,
  1350. msgConfirmText: msgConfirmText,
  1351. silenceLogin: silenceLogin,
  1352. getWXUserProfile: getWXUserProfile,
  1353. updataWxInfos: updataWxInfos,
  1354. saveBehavior: saveBehavior,
  1355. getBehavior: getBehavior
  1356. }