serverDetails.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. const api = require('../../../utils/api.js');
  2. const login = require('../../../utils/index.js');
  3. var app=getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. index:0,
  10. mask:false,
  11. showText:'显示更多',
  12. dis:false,
  13. keepImg:'../../../images/keep.png'
  14. },
  15. previewimg:function(e){
  16. var imgList=[]
  17. imgList.push(e.currentTarget.dataset.url)
  18. wx.previewImage({
  19. urls: imgList,
  20. })
  21. },
  22. // 底部跳转
  23. navigator:function(e){
  24. let that=this
  25. let getUserInfo = login.default.getUserInfo();
  26. getUserInfo.then((resolve, reject) => {
  27. that.data.userInfo = resolve
  28. if (!that.data.userInfo.id) {
  29. return false
  30. }else{
  31. if (that.data.userInfo.isRealname != 1) {
  32. wx.showToast({
  33. title: '请先完善用户信息',
  34. icon: 'none'
  35. })
  36. return false
  37. }
  38. if (!that.data.userInfo) {
  39. login.default.auth()
  40. return false
  41. }
  42. let frIsYesNo = that.data.guide.preService.forUser.indexOf('法人')
  43. let grIsYesNo = that.data.guide.preService.forUser.indexOf('个人')
  44. if(!e.currentTarget.dataset.type){
  45. switch (this.data.flag) {
  46. case '1':
  47. if (that.data.userInfo.identity != 0) {
  48. wx.showToast({
  49. title: '企业身份不能办理个人事项',
  50. icon: 'none'
  51. })
  52. return false
  53. }
  54. break;
  55. case '2':
  56. if (that.data.userInfo.identity != 1) {
  57. wx.showToast({
  58. title: '个人身份不能办理企业事项',
  59. icon: 'none'
  60. })
  61. return false
  62. }
  63. break
  64. }
  65. if (that.data.search) {
  66. if (that.data.userInfo.identity != 1 && grIsYesNo == -1) {
  67. wx.showToast({
  68. title: '个人身份不能办理企业事项',
  69. icon: 'none'
  70. })
  71. return false
  72. } else {
  73. if (that.data.userInfo.identity != 0 && frIsYesNo == -1) {
  74. wx.showToast({
  75. title: '企业身份不能办理个人事项',
  76. icon: 'none'
  77. })
  78. return false
  79. }
  80. }
  81. }
  82. if (that.data.collecct) {
  83. if (that.data.userInfo.identity != 1 && grIsYesNo == -1) {
  84. wx.showToast({
  85. title: '个人身份不能办理企业事项',
  86. icon: 'none'
  87. })
  88. return false
  89. } else {
  90. if (that.data.userInfo.identity != 0 && frIsYesNo == -1) {
  91. wx.showToast({
  92. title: '企业身份不能办理个人事项',
  93. icon: 'none'
  94. })
  95. return false
  96. }
  97. }
  98. }
  99. }
  100. if (e.currentTarget.dataset.type =='switchTab') {
  101. wx.setStorageSync('unid', e.currentTarget.dataset.unid)
  102. wx.switchTab({
  103. url: e.currentTarget.dataset.url,
  104. })
  105. return false
  106. }
  107. wx.navigateTo({
  108. url: e.currentTarget.dataset.url,
  109. })
  110. }
  111. })
  112. },
  113. nav(e){
  114. },
  115. // 拨打咨询电话
  116. call:function(e){
  117. wx.makePhoneCall({
  118. phoneNumber: e.currentTarget.dataset.phone,
  119. })
  120. },
  121. // 收藏
  122. keep:function(){
  123. if(!wx.getStorageSync('userId')){
  124. let getUserInfo = login.default.getUserInfo();
  125. }else{
  126. let that = this
  127. wx.showLoading({
  128. title: '请稍后',
  129. })
  130. var zhllCollect = {}
  131. zhllCollect.type = 1
  132. zhllCollect.serviceUnid = that.data.guide.preService.unid
  133. zhllCollect.serviceName = that.data.guide.preService.serviceName
  134. zhllCollect.userId = wx.getStorageSync('userId')
  135. wx.request({
  136. url: api.addCollect,
  137. data: zhllCollect,
  138. method: 'POST',
  139. dataType: 'json',
  140. responseType: 'text',
  141. success: function (res) {
  142. console.log(res)
  143. // if (that.data.keep) {
  144. // that.setData({
  145. // keepImg: '../../../images/keep.png'
  146. // })
  147. // that.data.keep = false;
  148. // wx.showToast({
  149. // title: '已取消收藏',
  150. // icon: 'none'
  151. // })
  152. // } else {
  153. that.setData({
  154. keepImg: '../../../images/keep_check.png'
  155. })
  156. that.data.keep = true
  157. that.setData({
  158. ['guide.isCollect']: 1
  159. })
  160. wx.showToast({
  161. title: '收藏成功',
  162. icon: 'none'
  163. })
  164. // }
  165. },
  166. fail: function (res) { },
  167. complete: function (res) { },
  168. })
  169. }
  170. },
  171. kindToggle:function(e){
  172. let that=this
  173. if (that.data.expand === e.currentTarget.dataset.value) {
  174. that.setData({
  175. dis: false,
  176. expand: e.currentTarget.dataset.value,
  177. })
  178. that.data.expand = ''
  179. } else {
  180. that.setData({
  181. dis: true,
  182. expand: e.currentTarget.dataset.value,
  183. })
  184. }
  185. },
  186. // 左右滑动切换
  187. swiper:function(e){
  188. this.setData({
  189. index:e.detail.current
  190. })
  191. },
  192. // 显示更多
  193. show:function(){
  194. let that=this
  195. if(that.data.ifshow){
  196. that.data.ifshow=false
  197. that.setData({
  198. show: that.data.ifshow,
  199. showText: '显示更多'
  200. })
  201. }else{
  202. that.data.ifshow=true
  203. that.setData({
  204. show:that.data.ifshow,
  205. showText:'收起'
  206. })
  207. }
  208. },
  209. /**
  210. * 生命周期函数--监听页面加载
  211. */
  212. onLoad: function (options) {
  213. var that = this
  214. that.data.flag=options.flag
  215. that.data.search = options.search
  216. that.data.collecct = options.collect
  217. wx.removeStorageSync('collecct')
  218. wx.showLoading({
  219. title: '正在加载',
  220. })
  221. wx.request({
  222. url: api.guide,
  223. data: { unid: options.unid, userId: wx.getStorageSync('userId'),type:1 },
  224. success(res) {
  225. wx.hideLoading();
  226. that.setData({
  227. guide: res.data.data,
  228. search: options.search == 1 ? options.search:''
  229. })
  230. }
  231. })
  232. wx.getSystemInfo({
  233. success: function (res) {
  234. that.setData({
  235. clientHeight: res.windowHeight-100
  236. });
  237. }
  238. })
  239. },
  240. // tab切换
  241. tab:function(e){
  242. let that=this
  243. that.setData({
  244. index:e.currentTarget.dataset.index,
  245. current_index: e.currentTarget.dataset.index,
  246. })
  247. },
  248. // 打开遮罩层
  249. mask:function(e){
  250. let that=this;
  251. that.data.docUrl=e.currentTarget.dataset.url
  252. that.data.docName=e.currentTarget.dataset.docname
  253. that.setData({
  254. mask:true,
  255. docName: that.data.docName
  256. })
  257. },
  258. // 关闭遮罩层
  259. clear:function(){
  260. let that=this;
  261. that.setData({
  262. mask:false
  263. })
  264. },
  265. // 拷贝
  266. copy:function(){
  267. let that=this
  268. wx.setClipboardData({
  269. data: that.data.docUrl,
  270. success: function (res) {
  271. }
  272. })
  273. },
  274. c:function(){
  275. this.setData({
  276. webUrl:false
  277. })
  278. },
  279. //预览文件
  280. preview:function(){
  281. let that=this
  282. console.log(wx.getSystemInfoSync())
  283. var arr=String(wx.getSystemInfoSync().system).split(' ')
  284. console.log(that.data.docUrl)
  285. if(arr[0]=='iOS'){
  286. wx.navigateTo({
  287. url: '/pages/handle/serverDetails/web/web?web=' + that.data.docUrl,
  288. })
  289. return false;
  290. }
  291. console.log(arr)
  292. wx.downloadFile({
  293. url: that.data.docUrl,
  294. header: {},
  295. success: function (res) {
  296. var filePath = res.tempFilePath;
  297. console.log(filePath);
  298. wx.openDocument({
  299. filePath: filePath,
  300. success: function (res) {
  301. console.log('打开文档成功')
  302. },
  303. fail: function (res) {
  304. console.log(res);
  305. },
  306. complete: function (res) {
  307. console.log(res);
  308. }
  309. })
  310. },
  311. fail: function (res) {
  312. console.log('文件下载失败');
  313. wx.showToast({
  314. title: '预览失败',
  315. icon:'none'
  316. })
  317. },
  318. complete: function (res) { },
  319. })
  320. },
  321. /**
  322. * 生命周期函数--监听页面初次渲染完成
  323. */
  324. onReady: function () {
  325. },
  326. /**
  327. * 生命周期函数--监听页面显示
  328. */
  329. onShow: function () {
  330. },
  331. /**
  332. * 生命周期函数--监听页面隐藏
  333. */
  334. onHide: function () {
  335. },
  336. /**
  337. * 生命周期函数--监听页面卸载
  338. */
  339. onUnload: function () {
  340. },
  341. /**
  342. * 页面相关事件处理函数--监听用户下拉动作
  343. */
  344. onPullDownRefresh: function () {
  345. },
  346. /**
  347. * 页面上拉触底事件的处理函数
  348. */
  349. onReachBottom: function () {
  350. },
  351. /**
  352. * 用户点击右上角分享
  353. */
  354. onShareAppMessage: function () {
  355. }
  356. })