123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757 |
- // pages/mine/mine.js
- var app = getApp();
- var utils = require("../../../utils/http");
- const util = require("../../../utils/util");
- var stoptime = 0;
- Page({
- data: {
- imgUrl: app.globalData.imgUrl,
- webUrl: '',
- titleType: 'article',
- firsTitext: '',
- videotagList: [],
- articletagList: [],
- secondtitlist: [],
- nowcasearr: [],
- wordtit: [],
- type: 1,
- nowTagText: '',
- page: 1,
- datashow: false,
- videoList: [],
- LeftdataList: [],
- RightdataList: [],
- creationtop: 120,
- artileList: [],
- shareflag: false,
- toolobj: {},
- nowtype: '',
- nowid: '',
- toptype: '',
- communame: '',
- casestylelist: [],
- filtrateflag: false,
- casestyletype: '',
- caselist: [],
- activitylist: [],
- evidencelist: [],
- leftevidencelist: [],
- rightevidencelist: [],
- wshareshow: false
- },
- onLoad: function (options) {
- var that = this;
- wx.showLoading({
- title: '加载中...',
- })
- // wx.hideShareMenu();
- this.setData({
- type: options.type
- })
- if (!!options.type) {
- that.setData({
- titleType: options.type
- })
- }
- that.sharedata();
- },
- casestylefun: function () {
- var that = this;
- utils.$get({
- url: app.globalData.webUrl + 'api/stylelist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- cmid: app.globalData.personMsg.binded.cmid
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- casestylelist: res.data.data
- })
- }
- }
- })
- },
- casecommunityfun: function () {
- var that = this;
- utils.$get({
- url: app.globalData.webUrl + 'api/communitylist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- cmid: app.globalData.personMsg.binded.cmid
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- casecommunitylist: res.data.data
- })
- that.getCitys();
- }
- }
- })
- },
- getCitys() {
- const _this = this
- const cities = this.data.casecommunitylist;
- // 按拼音排序
- cities.sort((c1, c2) => {
- let pinyin1 = c1.pinyin;
- let pinyin2 = c2.pinyin;
- return pinyin1.localeCompare(pinyin2)
- })
- // 添加首字母
- const map = new Map()
- for (const city of cities) {
- const alpha = city.pinyin.charAt(0).toUpperCase()
- if (!map.has(alpha)) map.set(alpha, [])
- map.get(alpha).push({
- name: city.name
- })
- }
- const keys = []
- for (const key of map.keys()) {
- keys.push(key)
- }
- keys.sort()
- const list = []
- for (const key of keys) {
- list.push({
- alpha: key,
- subItems: map.get(key)
- })
- }
- for (let i = 0; i < list.length; i++) {
- for (let j = 0; j < cities.length; j++) {
- if (list[i].subItems[0].name == cities[j].name) {
- list[i].case_num = cities[j].case_num;
- list[i].id = cities[j].id;
- }
- }
- }
- _this.setData({
- list: list
- })
- },
- materialcasetap: function (e) {
- this.setData({
- toptype: e.currentTarget.dataset.type,
- filtrateflag: true
- })
- },
- dothis: function () {},
- closefiltratetap: function () {
- this.setData({
- filtrateflag: false
- })
- },
- deltap(e) {
- var that = this;
- that.setData({
- commu_id: '',
- communame: ''
- })
- that.sharedata();
- },
- delareatap: function (e) {
- var that = this;
- that.setData({
- square_start: '',
- square_end: '',
- })
- that.sharedata();
- },
- casestyletap: function (e) {
- this.setData({
- casestyletype: e.currentTarget.dataset.type
- })
- this.sharedata();
- },
- sharedata: function () {
- var that = this;
- that.setData({
- page: 1
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/share/uclist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: that.data.page,
- limit: 15,
- type: that.data.titleType,
- label: that.data.firsTitext,
- ctype: that.data.nowTagText
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.createlist(res.data.data);
- }
- wx.hideLoading();
- }
- })
- },
- changeTap: function (e) {
- var that = this;
- that.setData({
- titleType: e.target.dataset.type
- })
- if (this.data.titleType == 'video') {
- that.setData({
- firsTitext: '',
- secondtitlist: [],
- nowTagText: ''
- })
- }
- if (this.data.titleType == 'article') {
- that.setData({
- firsTitext: '',
- secondtitlist: [],
- nowTagText: ''
- })
- }
- this.sharedata();
- // setTimeout(function(){
- // that.setght();
- // },100)
- },
- firsttap: function (e) {
- var that = this;
- that.setData({
- firsTitext: e.target.dataset.text
- })
- if (e.target.dataset.type == 1) {
- if (e.target.dataset.text != '') {
- that.setData({
- nowTagText: '',
- secondtitlist: that.data.videotagList[e.target.dataset.idx].sonLabel
- })
- } else {
- that.setData({
- nowTagText: '',
- secondtitlist: ''
- })
- }
- this.sharedata();
- } else if (e.target.dataset.type == 2) {
- if (e.target.dataset.text != '') {
- that.setData({
- nowTagText: '',
- secondtitlist: that.data.articletagList[e.target.dataset.idx].sonLabel
- })
- } else {
- that.setData({
- nowTagText: '',
- secondtitlist: ''
- })
- }
- this.sharedata();
- }
- // setTimeout(function(){
- // that.setght();
- // },100)
- },
- videoTagTap: function (e) {
- var that = this;
- that.setData({
- nowTagText: e.target.dataset.text
- })
- this.sharedata();
- },
- articleTagTap: function (e) {
- this.setData({
- nowTagText: e.target.dataset.text
- })
- this.sharedata();
- },
- sharealertap: function (e) {
- var that = this;
- that.setData({
- nowflag: true
- })
- if (e.currentTarget.dataset.type == 'article') {
- that.setData({
- nowtype: 'article',
- nowid: e.currentTarget.dataset.aid,
- })
- } else if (e.currentTarget.dataset.type == 'video') {
- that.setData({
- nowtype: 'video',
- nowid: e.currentTarget.dataset.aid,
- })
- } else if (e.currentTarget.dataset.type == 'materialCase') {
- that.setData({
- nowtype: 'materialCase',
- nowid: e.currentTarget.dataset.aid,
- })
- } else if (e.currentTarget.dataset.type == 'activity') {
- that.setData({
- nowtype: 'activity',
- nowid: e.currentTarget.dataset.aid,
- })
- } else if (e.currentTarget.dataset.type == 'materialEvidence') {
- that.setData({
- nowtype: 'materialEvidence',
- nowid: e.currentTarget.dataset.eid,
- })
- }
- this.setData({
- wshareshow: true
- })
- },
- shareurltap: function () {
- var that = this;
- wx.showLoading({
- title: '加载中...',
- })
- if (that.data.nowtype == 'article') {
- util.schemefun('/share/pages/articleshare/articleshare', 'aid=' + that.data.nowid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.nowid, 'article', '');
- } else if (that.data.nowtype == 'video') {
- util.schemefun('/share/pages/videoshare/videoshare', 'vid=' + that.data.nowid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.nowid, 'video', '');
- } else if (that.data.nowtype == 'materialCase') {
- util.schemefun('/share/pages/materialcase/materialcase', 'cid=' + that.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.nowid, 'materialCase', '');
- } else if (that.data.nowtype == 'activity') {
- util.schemefun('/share/pages/activitymsg/activitymsg', 'aid=' + this.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.nowid, 'activity', '');
- } else if (that.data.nowtype == 'materialEvidence') {
- util.schemefun('/share/pages/publicpraisemsg/publicpraisemsg', 'eid=' + that.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.nowid, 'materialEvidence', '');
- }
- this.sharelogtap();
- },
- sharelogtap: function (e) {
- var that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/share/addlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.nowid,
- type: that.data.nowtype
- },
- success: function (r) {}
- })
- },
- wordTagTap: function (e) {
- var that = this;
- if (that.data.wordTagNum == e.target.dataset.text) {
- that.setData({
- wordTagNum: ''
- })
- } else {
- that.setData({
- wordTagNum: e.target.dataset.text
- })
- }
- },
- setght: function () {
- var that = this;
- const query = wx.createSelectorQuery()
- query.select('.collectedTitle').boundingClientRect();
- query.exec(function (res) {
- // console.log(res[0])
- that.setData({
- creationtop: res[0].height
- })
- })
- },
- jsLine: function () {
- var that = this;
- },
- activityTap: function (e) {
- wx.navigateTo({
- url: "/index/pages/sharecasemsg/sharecasemsg?cid=" + e.target.dataset.aid + '&vtype=mycreation',
- });
- },
- imgLoad: function () {
- var that = this;
- var leftlist = that.data.LeftdataList;
- var rightlist = that.data.RightdataList;
- var videolist = that.data.videoList;
- if (that.data.videoList.length == 0) {
- return false
- }
- if (videolist.length == 0) {
- return false;
- }
- if (leftlist.length == 0) {
- leftlist.push(videolist[0]);
- videolist.shift();
- that.setData({
- videoList: videolist,
- LeftdataList: leftlist,
- RightdataList: rightlist
- })
- } else {
- var leftheight, rightheight;
- const query = wx.createSelectorQuery()
- query.select('.videoshareListLeft').boundingClientRect();
- query.exec(function (res) {
- leftheight = res[0].height;
- const queryright = wx.createSelectorQuery()
- queryright.select('.videoshareListRight').boundingClientRect();
- queryright.exec(function (rs) {
- leftlist = that.data.LeftdataList;
- rightlist = that.data.RightdataList;
- videolist = that.data.videoList;
- rightheight = rs[0].height;
- if (leftheight <= rightheight) {
- leftlist.push(videolist[0]);
- videolist.shift();
- } else {
- var str = videolist.shift();
- rightlist.push(str);
- }
- that.setData({
- videoList: videolist,
- LeftdataList: leftlist,
- RightdataList: rightlist
- })
- })
- })
- }
- },
- setpostertap: function () {
- let that = this;
- let type = that.data.nowtype;
- wx.navigateTo({
- url: '/index/pages/setposter/setposter?type=' + type + '&aid=' + this.data.nowid + "&listshare=",
- })
- },
- createlist: function (list) {
- var that = this;
- if (that.data.titleType == 'video') {
- var videoList = that.data.videoList;
- that.setData({
- datashow: true,
- LeftdataList: [],
- RightdataList: [],
- })
- var arr = list;
- // 数据渲染成功后,隐藏下拉刷新的状态
- videoList = videoList.concat(arr);
- that.setData({
- videoList: videoList
- })
- that.imgLoad();
- } else if (that.data.titleType == 'article') {
- that.setData({
- artileList: list,
- datashow: true
- })
- } else if (that.data.titleType == 'tool') {
- that.setData({
- toolobj: list
- })
- } else if (that.data.titleType == 'materialCase') {
- that.setData({
- caselist: list
- })
- } else if (that.data.titleType == 'activity') {
- that.setData({
- activitylist: list
- })
- } else if (that.data.titleType == 'materialEvidence') {
- var evidencelist = that.data.evidencelist;
- that.setData({
- datashow: true,
- leftevidencelist: [],
- rightevidencelist: [],
- })
- var arr = list;
- // 数据渲染成功后,隐藏下拉刷新的状态
- evidencelist = evidencelist.concat(arr);
- that.setData({
- evidencelist: evidencelist
- })
- that.evidenceimgLoad();
- }
- // setTimeout(function(){
- // that.setght();
- // },200)
- },
- evidenceimgLoad: function () {
- var that = this;
- var that = this;
- var leftlist = that.data.leftevidencelist;
- var rightlist = that.data.rightevidencelist;
- var indexlist = that.data.evidencelist;
- if (indexlist.length == 0) {
- return false;
- }
- if (leftlist.length == 0) {
- leftlist.push(indexlist[0]);
- indexlist.shift();
- that.setData({
- evidencelist: indexlist,
- leftevidencelist: leftlist,
- rightevidencelist: rightlist
- })
- } else {
- var leftheight, rightheight;
- const query = wx.createSelectorQuery()
- query.select('.leftpublicpraisebox').boundingClientRect();
- query.exec(function (res) {
- leftheight = res[0].height;
- const queryright = wx.createSelectorQuery()
- queryright.select('.rightpublicpraisebox').boundingClientRect();
- queryright.exec(function (rs) {
- leftlist = that.data.leftevidencelist;
- rightlist = that.data.rightevidencelist;
- indexlist = that.data.evidencelist;
- rightheight = rs[0].height;
- if (leftheight <= rightheight) {
- leftlist.push(indexlist[0]);
- indexlist.shift();
- } else {
- var str = indexlist.shift();
- rightlist.push(str);
- }
- that.setData({
- evidencelist: indexlist,
- leftevidencelist: leftlist,
- rightevidencelist: rightlist
- })
- })
- })
- }
- },
- articleTap: function (e) {
- wx.navigateTo({
- url: "/pages/articleshare/articleshare?aid=" + e.target.dataset.aid + '&vtype=mycreation',
- });
- },
- wordMsgTap: function (e) {
- var that = this;
- wx.navigateTo({
- url: "/pages/other/other?type=22&vid=" + e.target.dataset.wid,
- })
- },
- videoTap: function (e) {
- var that = this;
- wx.navigateTo({
- url: "/pages/videoshare/videoshare?vid=" + e.target.dataset.vid + '&vtype=mycreation',
- });
- },
- onReady: function () {
- },
- onPlay: function () {
- },
- onPlayNav: function () {
- },
- onShow: function () {
- stoptime = 0;
- setTimeout(function () {
- stoptime = stoptime * 1 + 1;
- }, 1000)
- app.globalData.sharevideo = false;
- app.globalData.sharearticle = false;
- app.globalData.sharecase = false;
- this.setData({
- shareflag: false
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- this.setData({
- webUrl: ''
- })
- var timearr = app.globalData.timearr,
- flag = false;
- for (var i = 0; i < timearr.length; i++) {
- if (timearr[i].type == 'mycreation') {
- timearr[i].time = timearr[i].time * 1 + stoptime * 1;
- flag = true;
- }
- }
- if (!flag) {
- var obj = {
- type: 'mycreation',
- time: stoptime
- };
- app.globalData.timearr.push(obj);
- } else {
- app.globalData.timearr = timearr;
- }
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- this.setData({
- webUrl: ''
- })
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- var that = this;
- that.setData({
- page: 1
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/share/uclist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: that.data.page,
- limit: 15,
- type: that.data.titleType,
- label: that.data.firsTitext,
- ctype: that.data.nowTagText
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.createlist(res.data.data);
- }
- wx.stopPullDownRefresh();
- wx.hideLoading();
- }
- })
- },
- publictap: function (e) {
- wx.navigateTo({
- url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + e.currentTarget.dataset.eid + "&title=" + e.currentTarget.dataset.title,
- })
- },
- casemsgtap: function (e) {
- wx.navigateTo({
- url: '/index/pages/casemsg/casemsg?cid=' + e.currentTarget.dataset.cid,
- })
- },
- activitytap: function (e) {
- wx.navigateTo({
- url: '/index/pages/activitymsg/activitymsg?aid=' + e.currentTarget.dataset.aid + "&collect=" + e.currentTarget.dataset.collect
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- var that = this;
- var page = that.data.page;
- page = page * 1 + 1;
- that.setData({
- page: page
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/share/uclist',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: that.data.page,
- limit: 15,
- type: that.data.titleType,
- label: that.data.firsTitext,
- ctype: that.data.nowTagText
- },
- success: function (res) {
- if (res.data.code == '0') {
- if (that.data.titleType == 'video') {
- var videoList = that.data.videoList;
- var flag = videoList.length == '0' ? true : false;
- var arr = res.data.data;
- // 数据渲染成功后,隐藏下拉刷新的状态
- videoList = videoList.concat(arr);
- that.setData({
- videoList: videoList
- })
- if (flag) {
- that.imgLoad();
- }
- } else if (that.data.titleType == 'article') {
- var artileList = that.data.artileList;
- artileList = artileList.concat(res.data.data);
- that.setData({
- artileList: artileList
- })
- } else if (that.data.titleType == 'materialCase') {
- let caselist = that.data.caselist;
- caselist = caselist.concat(res.data.data);
- that.setData({
- caselist: caselist
- })
- } else if (that.data.titleType == 'activity') {
- let activitylist = that.data.activitylist;
- activitylist = activitylist.concat(res.data.data);
- that.setData({
- activitylist: activitylist
- })
- } else if (that.data.titleType == 'materialEvidence') {
- let evidencelist = that.data.evidencelist;
- var arrflag = false
- if (evidencelist.length != 0) {
- arrflag = true;
- }
- for (let i = 0; i < res.data.data.length; i++) {
- evidencelist.push(res.data.data[i])
- }
- that.setData({
- evidencelist: evidencelist
- })
- if (!arrflag) {
- that.evidenceimgLoad();
- }
- }
- }
- wx.hideLoading();
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function (e) {
- // var that=this;
- // var imgsrc=e.target.dataset.src;
- // this.setData({
- // shareflag:true
- // })
- // var obj={};
- // if(that.data.titleType=='article'){
- // obj={
- // title: e.target.dataset.title,
- // imageUrl:imgsrc,
- // path: '/index/pages/articleshare/articleshare?aid='+e.target.dataset.aid+'&userid='+app.globalData.personMsg.id,
- // };
- // }else if(that.data.titleType=='video'){
- // obj={
- // title: e.target.dataset.title,
- // imageUrl:imgsrc,
- // path: '/index/pages/videoshare/videoshare?vid='+e.target.dataset.vid+'&userid='+app.globalData.personMsg.id,
- // }
- // }
- // return obj
- // }
- })
|