From 99062299fa4bdf08696ad1f90450a6c50baf892b Mon Sep 17 00:00:00 2001 From: lnn19986213 <1667908750@qq.com> Date: Fri, 1 Mar 2024 13:31:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pagesA/my/My.vue | 14 +- src/pagesB/PersonalCenter/PersonalCenter.vue | 5 + src/pagesC/Login/Login.vue | 154 ++++++++++++------ .../PolicyExpress/PolicyExpressDetail.vue | 126 +++++++------- src/pagesC/activity/activityDetail.vue | 138 +++++++++++----- src/pagesC/moreFun/moreFun.vue | 56 +++---- src/request/interface.js | 4 +- 7 files changed, 305 insertions(+), 192 deletions(-) diff --git a/src/pagesA/my/My.vue b/src/pagesA/my/My.vue index 53e9b6f..7fe12d4 100644 --- a/src/pagesA/my/My.vue +++ b/src/pagesA/my/My.vue @@ -13,15 +13,15 @@ - + {{ userName }} - + - + @@ -430,15 +430,11 @@ .sf_textA { - width: 146rpx; - height: 48rpx; - margin-top: 12rpx; + height: 50rpx; } .sf_textB { - width: 166rpx; - height: 48rpx; - margin-top: 12rpx; + height: 50rpx; } .sf_textC { diff --git a/src/pagesB/PersonalCenter/PersonalCenter.vue b/src/pagesB/PersonalCenter/PersonalCenter.vue index 5ec76a1..f6179c0 100644 --- a/src/pagesB/PersonalCenter/PersonalCenter.vue +++ b/src/pagesB/PersonalCenter/PersonalCenter.vue @@ -179,6 +179,11 @@ // 因为异步问题 res 打印出来的是 最后的结果 console.log("res", res.data); this.userInfoObj = res.data; + if(!res.data.association){ + this.userInfoObj.association = { + name: '' + } + } if(res.data.artAtt==""){ this.userInfoObj.artAtt= JSON.stringify([""]) } diff --git a/src/pagesC/Login/Login.vue b/src/pagesC/Login/Login.vue index 2679c1c..b546a9f 100644 --- a/src/pagesC/Login/Login.vue +++ b/src/pagesC/Login/Login.vue @@ -35,7 +35,7 @@ - + @@ -136,6 +136,7 @@ appId: 'wx55b187e6ed92e2ac', phone: '', jscode: '', + phone_code: '' }, isWx: false, imgFile: '', @@ -147,7 +148,6 @@ }, methods: { getImgFile() { - // 获取手机号 this.http.request('/auth/getCodes', {}, "GET").then(res => { if (res.code == 200) { this.imgFile = res.data.captchaImg @@ -179,18 +179,88 @@ url: '/pagesC/Login/RemeberPW' }) }, - // close() { - // this.show = false - // uni.showToast({ - // title: '您拒绝了请求', - // icon: "error", + + + // 旧版微信登录 + // getPhoneNumber(e) { + // if (e.detail.errMsg == "getPhoneNumber:ok") { + // this.wxDate.phone_encryptedData = e.detail.encryptedData + // this.wxDate.phone_iv = e.detail.iv + // this.getNumber(e.detail.code) + // } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { + // uni.showToast({ + // title: '您拒绝了请求', + // icon: "error", + // }); + // } + // }, + // getNumber(code) { + // this.load = true + // // 获取手机号 + // this.http.request('/auth/wx/getPhone?code=' + code, {}, "POST").then(res => { + // if (res.code == 200) { + // this.wxDate.phone = res.data.phone_info.phoneNumber + // this.wechatLogin() + // } + // }).catch(e => { + // this.load = false + // uni.showToast({ + // title: e.data.message, + // icon: "none", + // }); + // }) + // }, + // wechatLogin() { + // let _this = this + // //检查登录态是否过期 + // uni.checkSession({ + // provider: 'weixin', + // success: function(loginRes) { + // console.log('checkSession成功', loginRes); + // }, + // fail: function(loginRes) { + // console.log('checkSession失败', loginRes); + // }, + // }); + + // //重新登录 + // let jsCode = '' + // uni.login({ + // provider: 'weixin', + // success: function(loginRes) { + // jsCode = loginRes.code; + // console.log('login重新登录', { + // loginRes + // }); + // _this.http.request('/auth/xcx_login', { + // code: jsCode, + // phone: _this.wxDate.phone + // }, "POST").then(res => { + // if (res.code == 200) { + // uni.setStorageSync('token', res.data.tokenValue) + // uni.redirectTo({ + // url: '/pages/pageHome/pageHome' + // }) + // } + // }).catch(e => { + // uni.showToast({ + // title: e.data.message, + // icon: "none", + // }); + // }) + // }, + // fail: function(loginRes) { + // console.log(loginRes) + // _this.load = false + // } // }); // }, + + // 新版微信登录 getPhoneNumber(e) { if (e.detail.errMsg == "getPhoneNumber:ok") { - this.wxDate.phone_encryptedData = e.detail.encryptedData - this.wxDate.phone_iv = e.detail.iv - this.getNumber(e.detail.code) + this.wxDate.phone_code = e.detail.code + this.getOpenId() } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { uni.showToast({ title: '您拒绝了请求', @@ -198,53 +268,16 @@ }); } }, - getNumber(code) { - this.load = true - // 获取手机号 - this.http.request('/auth/wx/getPhone?code=' + code, {}, "POST").then(res => { - if (res.code == 200) { - this.wxDate.phone = res.data.phone_info.phoneNumber - this.wechatLogin() - } - }).catch(e => { - this.load = false - uni.showToast({ - title: e.data.message, - icon: "none", - }); - }) - }, - wechatLogin() { + getOpenId() { let _this = this - //检查登录态是否过期 - uni.checkSession({ - provider: 'weixin', - success: function(loginRes) { - console.log('checkSession成功', loginRes); - }, - fail: function(loginRes) { - console.log('checkSession失败', loginRes); - }, - }); - - //重新登录 let jsCode = '' uni.login({ provider: 'weixin', success: function(loginRes) { jsCode = loginRes.code; - console.log('login重新登录', { - loginRes - }); - _this.http.request('/auth/xcx_login', { - code: jsCode, - phone: _this.wxDate.phone - }, "POST").then(res => { + _this.http.request('/auth/wx/getOpenId?code=' + jsCode, {}, "POST").then(res => { if (res.code == 200) { - uni.setStorageSync('token', res.data.tokenValue) - uni.redirectTo({ - url: '/pages/pageHome/pageHome' - }) + _this.wechatLogin(res.data) } }).catch(e => { uni.showToast({ @@ -259,6 +292,27 @@ } }); }, + wechatLogin(val) { + this.http.request('/auth/wx/getPhoneByOpenId', { + code: this.wxDate.phone_code, + openId: val + }, "POST").then(res => { + if (res.code == 200) { + uni.setStorageSync('token', res.data.tokenValue) + uni.redirectTo({ + url: '/pages/pageHome/pageHome' + }) + } + }).catch(e => { + uni.showToast({ + title: e.data.message, + icon: "none", + }); + }) + }, + + + login() { if (this.tab == 0) { this.load = true diff --git a/src/pagesC/PolicyExpress/PolicyExpressDetail.vue b/src/pagesC/PolicyExpress/PolicyExpressDetail.vue index 2127eaf..16f5381 100644 --- a/src/pagesC/PolicyExpress/PolicyExpressDetail.vue +++ b/src/pagesC/PolicyExpress/PolicyExpressDetail.vue @@ -25,11 +25,8 @@ - - - - - + + {{item.name}} @@ -43,9 +40,9 @@ export default { data() { return { - list:[], - list2:[], - id:'', + list: [], + list2: [], + id: '', iswx: 0, detailData: {}, } @@ -59,34 +56,33 @@ // #ifdef MP-WEIXIN this.iswx = 0 // #endif - + // #ifndef MP-WEIXIN //除了小程序 this.iswx = 1 // #endif }, - methods:{ - getData(){ + methods: { + getData() { let _this = this this.http.request('/policy/details/' + this.id, {}, "GET").then(res => { if (res.code == 200) { if (res.data.files) { let fileArr = res.data.files.split(',') - fileArr.forEach(function(item) { + fileArr.forEach(function(item,index) { let gs = item.substr(item.lastIndexOf(".") + 1) - console.log(item,gs) - if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == 'gif' || gs == 'tif' || gs == 'tiff') { + if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == + 'gif' || gs == 'tif' || gs == 'tiff') { _this.list.push(item) - } else if (gs == 'pdf') { + } else { _this.list2.push({ - name: res.data.title + '.' + gs, + name: res.data.title + index + '.' + gs, img: '../../static/fileImg/pdfS.png', url: item, }) - } + } }) } - console.log(this.list2) this.detailData = res.data } }).catch(e => { @@ -98,24 +94,44 @@ }, //点击文件 downLoad(val) { - this.contractUrl = val - if(this.iswx == 0){ - this.openPDF() - }else if(this.iswx == 1){ - uni.navigateTo({ - url: "../ArtWorks/webView?url=" + this.contractUrl + let urlPath = val + const token = uni.getStorageSync('token') + if (this.iswx == 0) { + wx.downloadFile({ + url: urlPath, //仅为示例,并非真实的资源 + header: { + 'Authorization': "Bearer " + token, + 'x-token': token + }, + success(res) { + // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容 + if (res.statusCode === 200) { + const filePath = res.tempFilePath; + wx.openDocument({ + filePath: filePath, + showMenu: true, + success: function(res) { + console.log(res, '打开文档成功'); + } + }); + } + } }) + } else { + window.location.href = urlPath } + }, } } + \ No newline at end of file diff --git a/src/pagesC/activity/activityDetail.vue b/src/pagesC/activity/activityDetail.vue index b0b6915..bdeba47 100644 --- a/src/pagesC/activity/activityDetail.vue +++ b/src/pagesC/activity/activityDetail.vue @@ -25,8 +25,15 @@ - + + + + + + + {{item.name}} + + @@ -39,22 +46,49 @@ id: '', serveList: {}, img: [], + list2: [], + iswx: 0, } }, onLoad(options) { this.id = options.id }, + onReady() { + // this.load = false + // #ifdef MP-WEIXIN + this.iswx = 0 + // #endif + // #ifndef MP-WEIXIN + //除了小程序 + this.iswx = 1 + // #endif + }, onShow() { + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'] + }) this.getList() }, - methods:{ + methods: { getList() { + let _this = this this.http.request('/dynamic/details/' + this.id, {}, "GET").then(res => { this.serveList = res.data - if(res.data.imagePath){ + if (res.data.imagePath) { this.img = res.data.imagePath.split(',') } + if (res.data.files) { + let fileArr = res.data.files.split(',') + fileArr.forEach(function(item,index) { + let gs = item.substr(item.lastIndexOf(".") + 1) + _this.list2.push({ + name: res.data.title + index + '.' + gs, + url: item, + }) + }) + } }).catch(e => { uni.showToast({ title: e.data.message, @@ -62,15 +96,46 @@ }); }) }, + //点击文件 + downLoad(val) { + let urlPath = val + const token = uni.getStorageSync('token') + if (this.iswx == 0) { + wx.downloadFile({ + url: urlPath, //仅为示例,并非真实的资源 + header: { + 'Authorization': "Bearer " + token, + 'x-token': token + }, + success(res) { + // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容 + if (res.statusCode === 200) { + const filePath = res.tempFilePath; + wx.openDocument({ + filePath: filePath, + showMenu: true, + success: function(res) { + console.log(res, '打开文档成功'); + } + }); + } + } + }) + } else { + window.location.href = urlPath + } + + }, } } + \ No newline at end of file diff --git a/src/pagesC/moreFun/moreFun.vue b/src/pagesC/moreFun/moreFun.vue index 793baa8..ccb6939 100644 --- a/src/pagesC/moreFun/moreFun.vue +++ b/src/pagesC/moreFun/moreFun.vue @@ -14,10 +14,11 @@ export default { data() { return { - list: [{ - imgUrl: '../../static/icon7.png', - label: '文艺援助' - }, + list: [ + // { + // imgUrl: '../../static/icon7.png', + // label: '文艺援助' + // }, { imgUrl: '../../static/icon8.png', label: '媒体宣传' @@ -26,10 +27,10 @@ imgUrl: '../../static/moreFun/moreFun3.png', label: '机构设置' }, - { - imgUrl: '../../static/moreFun/moreFun4.png', - label: '资料查找' - }, + // { + // imgUrl: '../../static/moreFun/moreFun4.png', + // label: '资料查找' + // }, { imgUrl: '../../static/moreFun/moreFun2.png', label: '文艺下乡' @@ -40,57 +41,48 @@ { imgUrl: '../../static/icon4.png', label: '线上看展' - }, - // { - // imgUrl: '../../static/icon5.png', - // label: '积分商城' - // }, + } ] }; }, methods: { SwitchPage(id) { switch (id) { + // case 0: + // uni.navigateTo({ + // url: "/pagesC/literHelp/literHelp" + // }) + // break; case 0: - uni.navigateTo({ - url: "/pagesC/literHelp/literHelp" - }) - break; - case 1: uni.navigateTo({ url: "/pagesC/mediaProp/mediaProp" }) break; - case 2: + case 1: uni.navigateTo({ url: "/pagesD/jgsz/index" }) break; - case 3: - uni.navigateTo({ - url: "/pagesC/DataSearch/DataSearch" - }) - break; - case 4: + // case 3: + // uni.navigateTo({ + // url: "/pagesC/DataSearch/DataSearch" + // }) + // break; + case 2: uni.navigateTo({ url: "/pagesD/wyxx/index" }) break; - case 5: + case 3: uni.navigateTo({ url: "/pagesB/ArtRace/ArtRace" }) break; - case 6: + case 4: uni.navigateTo({ url: "/pagesD/xskz/index" }) break; - case 7: - uni.redirectTo({ - url: "/pagesC/shop/Shop?typesOf=3" - }) - break; } } } diff --git a/src/request/interface.js b/src/request/interface.js index 6ed2d37..ede6abe 100644 --- a/src/request/interface.js +++ b/src/request/interface.js @@ -5,9 +5,9 @@ export default { config: { - // baseUrl: "http://192.168.2.48:8080/h5/api", //俞燕红-小程序不能配跨域 + baseUrl: "http://192.168.2.48:8080/h5/api", //俞燕红-小程序不能配跨域 // baseUrl: "/pre", //俞燕红-跨域 - baseUrl: "https://yxx.ydool.net/h5/api", //线上 + // baseUrl: "https://yxx.ydool.net/h5/api", //线上 // baseUrl: "/h5/api", //h5 header: { 'Content-Type': 'application/json;charset=UTF-8',