123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 |
- const app = getApp();
- var utils = require("../../../utils/http"),
- page = 1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.imgUrl,
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- isShow: true,
- designerId: '',
- designId: '',
- designerobj: {},
- caselist: [],
- loginFlag: true, //false是没有个人信息
- phoneflag: false, //true有手机号
- caseallshow: false,
- companyobj: {},
- shareobj: {},
- employeeflag: false, //false是用户,true是员工
- type: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.showLoading({
- title: '加载中...',
- })
- wx.hideHomeButton();
- this.setData({
- imgUrl: app.globalData.imgUrl,
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- designerId: options.did,
- designId: options.did,
- })
- if (!!options.type) {
- this.setData({
- phoneflag: app.globalData.phone,
- type: options.type
- })
- this.designermsg();
- } else {
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
- app.globalData.clientype = options.ctp;
- app.globalData.shareuserid = options.uid;
- this.login();
- }
- },
- sharecompany: function () {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/index/content_belong_company',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- client_type: app.globalData.clientype,
- uid: app.globalData.shareuserid
- },
- success: function (res) {
- if (res.data.code == '0') {
- app.globalData.companyobj=res.data.data;
- that.setData({
- companyobj: res.data.data
- })
- }
- },
- complete(res) {
- wx.hideLoading()
- }
- })
- },
- login: function () {
- var that = this;
- wx.login({
- success: function (data) {
- if (data.errMsg == 'login:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/code2session',
- data: {
- code: data.code,
- share: app.globalData.shareuserid,
- client_type:app.globalData.clientype
- },
- success: function (r) {
- if (r.data.code == '0') {
- app.globalData.sharepersonobj = r.data.share;
- app.globalData.token = r.data.token;
- that.setData({
- shareobj: app.globalData.sharepersonobj,
- })
- that.sharecompany();
- // r.data.user='';
- if (r.data.user != null && (!!r.data.user.headimgurl && r.data.user.headimgurl != "" || !!r.data.user.nickname && r.data.user.nickname != "" && r.data.user.nickname != '游客')) {
- that.setData({
- loginFlag: true,
- employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
- })
- app.globalData.personMsg = r.data.user;
- app.globalData.userflag = false; //有个人信息
- var nickname = r.data.user.nickname;
- var phone = r.data.user.phone;
- app.globalData.phone = false; //没有手机号
- if (r.data.user.phone == '') {
- that.setData({
- phoneflag: false
- })
- wx.hideLoading();
- app.globalData.phone = false; //没有手机号
- } else {
- that.setData({
- phoneflag: true
- })
- app.globalData.phone = true; //有手机号
- }
- that.designermsg();
- } else {
- wx.hideLoading();
- that.setData({
- loginFlag: false
- })
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 500)
- } else {
- wx.hideLoading()
- }
- }
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- otherlistfun() {
- this.setData({
- caseallshow: true
- })
- },
- designermsg() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/designer_read',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.designerId
- },
- success: function (res) {
- that.setData({
- loginFlag:true
- })
- if (res.data.code == "0") {
- that.setData({
- designerobj: res.data.data
- })
- }
- wx.hideLoading()
- }
- })
- this.casefun();
- },
- casefun() {
- const that = this;
- page = 1;
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/designer_case_list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.designId,
- page: 1,
- limit: 10,
- },
- success: function (res) {
- if (res.data.code == "0") {
- that.setData({
- caselist: res.data.data
- })
- }
- wx.hideLoading()
- }
- })
- },
- golastap: function () {
- wx.navigateBack()
- },
- goindextap: function () {
- wx.reLaunch({
- url: '/pages/index/index?state=1',
- })
- },
- openVRLink(e) {
- let vrlink = e.currentTarget.dataset.vrlink;
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&aid=' + id,
- })
- },
- apointap: function (e) {
- if (this.data.designerobj.make == 1) {
- wx.showToast({
- title: '不能重复预约!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/designer_make',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- designer_id: that.data.designerobj.designer_id,
- designer_name: that.data.designerobj.name,
- share_uid: app.globalData.shareuserid
- },
- success: function (res) {
- if (res.data.code == "0") {
- let designerobj = that.data.designerobj;
- designerobj.make = 1;
- that.setData({
- designerobj: designerobj
- })
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- })
- },
- loginfun() {
- var that = this;
- wx.login({
- success: function (data) {
- if (data.errMsg == 'login:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/code2session',
- data: {
- code: data.code,
- share: app.globalData.shareuserid,
- client_type:app.globalData.clientype
- },
- success: function (r) {
- if (r.data.code == '0') {
- app.globalData.sharepersonobj = r.data.share;
- app.globalData.token = r.data.token;
- if (r.data.user != null && (!!r.data.user.headimgurl && r.data.user.headimgurl != "" || !!r.data.user.nickname && r.data.user.nickname != "")) {
- that.setData({
- employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
- })
- app.globalData.personMsg = r.data.user;
- app.globalData.use_id = r.data.user.id;
- app.globalData.userflag = false;//有个人信息
- }
- }
- }
- })
- }
- }
- })
- },
- getUserInfoTap: function (res) {
- var that = this;
- wx.showLoading();
- if (res.detail.errMsg == 'getUserInfo:ok') {
- utils.$post({
- method: "POST", //TESTAPIURL APIURL/users/auth
- url: app.globalData.webUrl + 'api/users/setUserInfo',
- data: {
- encryptedData: res.detail.encryptedData,
- iv: res.detail.iv,
- rawData: res.detail.rawData,
- signature: res.detail.signature,
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- if (r.data.code == '0') {
- that.loginfun();
- that.setData({
- loginFlag: true,
- phoneflag: false
- })
- app.globalData.userflag = true; //有个人信息
- } else {
- if (r.data.code == '403') {
- that.login();
- return false
- }
- wx.showToast({
- title: r.data.msg,
- icon: "none",
- duration: 2000
- });
- }
- }
- })
- }
- },
- getUserProfile: function () {
- var that = this;
- wx.getUserProfile({
- lang: 'zh_CN',
- desc: '为了更好的体验申请获取以下信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- if (res.errMsg == "getUserProfile:ok") {
- wx.showLoading();
- utils.$post({
- method: "POST", //TESTAPIURL APIURL/users/auth
- url: app.globalData.webUrl + 'api/users/setUserInfo',
- data: {
- encryptedData: res.encryptedData,
- iv: res.iv,
- rawData: res.rawData,
- signature: res.signature,
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- setTimeout(res => {
- wx.hideLoading()
- }, 500)
- if (r.data.code == '0') {
- that.loginfun();
- that.setData({
- loginFlag: true,
- phoneflag: false
- })
- app.globalData.userflag = true; //有个人信息
- } else {
- if (r.data.code == '403') {
- that.login();
- return false
- }
- wx.showToast({
- title: r.data.msg,
- icon: "none",
- duration: 2000
- });
- }
- }
- })
- }
- }
- })
- },
- getPhoneNumberTap: function (res) {
- var that = this;
- if (res.detail.errMsg == 'getPhoneNumber:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/setUserMobile',
- data: {
- encryptedData: res.detail.encryptedData,
- iv: res.detail.iv
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- if (r.data.code == '0') {
- // wx.showLoading({
- // title: '加载中',
- // })
- app.globalData.phone = true;
- that.setData({
- phoneflag: true
- })
- that.apointap(res);
- } else {
- that.setData({
- errorText: r.data.msg,
- errorflag: true
- })
- }
- }
- })
- }
- },
- casemsgtap: function (e) {
- wx.navigateTo({
- url: '/share/pages/materialcase/materialcase?type=3&cid=' + e.currentTarget.dataset.sid + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype
- })
- },
- showdesctap() {
- this.setData({
- isShow: this.data.isShow ? false : true
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- page = 1;
- this.setData({
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- phoneflag: app.globalData.phone
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- const that = this;
- page = page * 1 + 1;
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/designer_case_list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.designId,
- page: page,
- limit: 10,
- },
- success: function (res) {
- let caselist = that.data.caselist;
- if (res.data.code == "0") {
- caselist = caselist.concat(res.data.data);
- that.setData({
- caselist: caselist
- })
- }
- wx.hideLoading()
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: app.globalData.companyobj.company_name + '设计师:' + this.data.designerobj.name,
- imageUrl: app.globalData.imgUrl + "xcx/designerlisticon.jpg",
- path: '/share/pages/designermsg/designermsg?uid=' + app.globalData.shareuserid + '&did=' + this.data.designId + '&ctp=' + app.globalData.clientype
- }
- }
- })
|