diff --git a/app.js b/app.js index 446bedd..d962278 100644 --- a/app.js +++ b/app.js @@ -22,7 +22,7 @@ App({ unique_key: "wechatxcx" }).then(res => { let data = JSON.parse(res.data); - data.isTest = data.isTest11?true:false; + data.isTest = data.isTest13?true:false; this.globalData.configJson = data }) diff --git a/app.json b/app.json index 738527c..635433c 100644 --- a/app.json +++ b/app.json @@ -5,6 +5,12 @@ "pages/search/index", "pages/search/list/index", "pages/login/index", + "pages/old/index", + "pages/old/user/index", + "pages/old/profile/index", + "pages/old/nickname/index", + "pages/old/linkman/index", + "pages/old/linkman/add/index", "pages/order/comment/index", "pages/order/coupon/index", "pages/order/pay/index", @@ -60,6 +66,7 @@ "pages/user/order/couponOrderInfo/index", "pages/user/order/hotelOrderInfo/index", "pages/user/order/postOrderInfo/index", + "pages/user/order/expressInfo/index", "pages/user/order/movieOrderInfo/index", "pages/user/order/activityOrderInfo/index", "pages/user/order/museumOrderInfo/index", diff --git a/pages/index/index.js b/pages/index/index.js index 64b1a2f..3f8f9e1 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -30,7 +30,9 @@ Page({ scrollLeft:0, videoPrize:false, prizeInfo:null, - otherPlat:null + otherPlat:null, + activeBannerIndex:0, + smBannerIndex:0 }, onLoad: function (options) { if(options.from){ @@ -79,6 +81,16 @@ Page({ onTabItemTap:function(e){ console.log(e,99999999) }, + changeBannerIndex:function(e){ + this.setData({ + activeBannerIndex:e.detail.current + }) + }, + changeSmBannerIndex:function(e){ + this.setData({ + smBannerIndex:e.detail.current + }) + }, // 一城百馆 city:function(){ wx.navigateToMiniProgram({ diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 6d813a7..9636f6e 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -1,25 +1,36 @@ + + + {{weather.max_temp}}° {{weather.weather}} + + + + 搜索想要的旅游产品或服务 - - - - - - - - - + + + + + + + + + + + + + + + + - + @@ -143,7 +149,7 @@ - + 更多 @@ -208,7 +214,7 @@ - + @@ -269,7 +275,7 @@ - + @@ -278,7 +284,7 @@ - + @@ -288,7 +294,7 @@ - + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index d378928..f5e32f2 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -10,29 +10,30 @@ } .top-box { display: flex; - padding: 14rpx 0; + padding: 10rpx 0; align-items: center; - margin: 0 20rpx; - justify-content: space-between; + margin: 0 30rpx; + justify-content: flex-start; + position: relative; + z-index: 1; } .top-box image { flex-shrink: 0; - width: 53rpx; - height: 53rpx; + width: 63rpx; + height: 63rpx; display: block; - margin-left: 14rpx; + margin-left: 18rpx; } .search-box { flex: 1; - width: 440rpx; + width: 100%; height: 64rpx; background: #F4F4F4; border-radius: 32rpx; display: flex; align-items: center; - color: #333; + color: #666; font-size: 25rpx; - margin: 0 20rpx; } .search-box .iconfont { font-size: 30rpx; @@ -52,6 +53,7 @@ font-size: 19rpx; margin-top: 20rpx; margin-left: -4rpx; + margin-right: 30rpx; } .top-icons { /* background: #FFFFFF; */ @@ -172,11 +174,13 @@ height: 154rpx; } .small-swiper-box { - margin: 85rpx 0; + margin: 83rpx 0; width: 100%; height: 154rpx; border-radius: 77rpx; overflow: hidden; + margin-bottom: 63rpx; + position: relative; } .product-tags { display: flex; @@ -314,7 +318,7 @@ .six-box { margin-top: 43rpx; display: flex; - margin-bottom: 60rpx; + margin-bottom: 50rpx; flex-wrap: wrap; justify-content: space-between; } @@ -605,4 +609,63 @@ } .other-plat:nth-child(4n){ margin-right: 0; +} +.old-btn { + position: absolute; + right: 0; + writing-mode:tb-rl; + margin-top: 142rpx; + color: #0B898E; + font-size: 29rpx; + width: 64rpx; + height: 140rpx; + display: flex; + align-items: center; + justify-content: center; + letter-spacing: 3rpx; + background: rgba(255, 255, 255, 0.7); + box-shadow: 0px 0px 13rpx 0px rgba(0, 0, 0, 0.3); + border-radius: 13rpx 0px 0px 13rpx; + font-weight: 500; + z-index: 1; +} +.top-bg-img { + display: block; + width: 100%; + position: absolute; + left: 0; +} +.dot-list { + display: flex; + position: absolute; + right: 43rpx; + bottom: 15rpx; +} +.dot { + width: 11rpx; + height: 11rpx; + background: #FFFFFF; + opacity: 0.4; + border-radius: 50%; + margin-left: 8rpx; +} +.dot.active { + opacity: 1; +} +.sm-dot-list { + left: 0; + justify-content: center; + bottom: 11rpx; +} +.sm-dot-list .dot { + width: 7rpx; + height: 7rpx; +} +.sm-dot-list .dot:nth-child(1){ + margin-left: 0; +} +.sm-dot-list .dot.active { + width: 20rpx; + height: 7rpx; + border-radius: 3rpx; } \ No newline at end of file diff --git a/pages/info/museumInfo/index.js b/pages/info/museumInfo/index.js index a3b31d1..11417b4 100644 --- a/pages/info/museumInfo/index.js +++ b/pages/info/museumInfo/index.js @@ -464,6 +464,12 @@ Page({ }, 200) } }, + goVr:function(){ + app.globalData.weburl = this.data.info.vr_info_url + wx.navigateTo({ + url: '/pages/pbService/web/index', + }) + }, /** * 生命周期函数--监听页面隐藏 diff --git a/pages/info/museumInfo/index.wxml b/pages/info/museumInfo/index.wxml index 0d276e0..1a77bfb 100644 --- a/pages/info/museumInfo/index.wxml +++ b/pages/info/museumInfo/index.wxml @@ -3,6 +3,10 @@ + + + VR景点 + diff --git a/pages/info/museumInfo/index.wxss b/pages/info/museumInfo/index.wxss index 9e55f09..0d5a8c1 100644 --- a/pages/info/museumInfo/index.wxss +++ b/pages/info/museumInfo/index.wxss @@ -285,4 +285,23 @@ margin-right: 10rpx; font-size: 26rpx; color: #0B898E; +} + +.vr-box { + width: 199rpx; + height: 64rpx; + background: rgba(0, 0, 0, 0.5); + border-radius: 0px 32rpx 32rpx 0px; + color: #FAFAFA; + justify-content: center; + font-size: 31rpx; + position: absolute; + margin-top: 240rpx; + left: 0; + z-index: 1; +} +.vr-box image { + width: 33rpx; + display: block; + margin-right: 10rpx; } \ No newline at end of file diff --git a/pages/old/index.js b/pages/old/index.js new file mode 100644 index 0000000..959d539 --- /dev/null +++ b/pages/old/index.js @@ -0,0 +1,66 @@ +// pages/old/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/old/index.json b/pages/old/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/old/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/old/index.wxml b/pages/old/index.wxml new file mode 100644 index 0000000..fd03ba0 --- /dev/null +++ b/pages/old/index.wxml @@ -0,0 +1,12 @@ + + + + + + 首页 + + + + 我的 + + diff --git a/pages/old/index.wxss b/pages/old/index.wxss new file mode 100644 index 0000000..2aa5673 --- /dev/null +++ b/pages/old/index.wxss @@ -0,0 +1,24 @@ +/* pages/old/index.wxss */ +.bottom { + position: fixed; + left: 0; + right: 0; + height: 175rpx; + background: #FFFFFF; + box-shadow: -1px 1px 16rpx 0px rgba(6, 0, 1, 0.1); + color: #999; + bottom: 0; +} +.bottom-item { + width: 50%; + text-align: center; +} +.bottom image { + width: 80rpx; + display: block; + margin: 0 auto; + margin-bottom: 10rpx; +} +.bottom-item.active { + color: #0B898E; +} \ No newline at end of file diff --git a/pages/old/linkman/add/index.js b/pages/old/linkman/add/index.js new file mode 100644 index 0000000..874530b --- /dev/null +++ b/pages/old/linkman/add/index.js @@ -0,0 +1,217 @@ +// pages/user/address/add/index.js +import util from "../../../../utils/util.js" +import user from "../../../../utils/https/user.js" +let app = getApp() +Page({ + + /** + * 页面的初始数据 + */ + data: { + isDefault:true, + region: [], + customItem: '', + typeItem:null, + formData:{ + }, + id:null, // 为null的时候是新增,否则是编辑 + types:[], + safeBottom:app.globalData.safeBottom, + selectIndex:0 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + id: options.id || null + }) + // 获取证件列表 + user.user_post("user/getCardTypeList", {}).then(r => { + console.log(r) + let data = []; + r.data.map(item=>{ + data.push(item.title) + }) + this.setData({ + types: r.data, + typeList:data + }) + if (this.data.id) { + user.user_post("user/getContactInfoById", { id: this.data.id }).then(res => { + res.data.isDefault = res.data.is_default == '1' ? true : false; + res.data.username = res.data.name; + res.data.mobile = res.data.tel; + res.data.idNumber = res.data.id_number; + this.setData({ + formData: res.data, + idTypeId: res.data.idcard_type, + selectIndex:r.data.findIndex(item=>item.type == res.data.idcard_type && item.code == res.data.document_type) + }) + }) + } + }) + + + // 如果id存在那么需要获取地址详情 + }, + // 设为默认 + setDefault:function(e){ + var formData = this.data.formData; + formData.isDefault = e.detail.value; + this.setData({ + formData: formData + }) + }, + // 输入监听 不是双向绑定啊 绝望 + nameInput:function(e){ + var formData = this.data.formData; + formData.username = e.detail.value; + this.setData({ + formData: formData + }) + }, + telInput:function(e){ + var formData = this.data.formData; + formData.mobile = e.detail.value; + this.setData({ + formData: formData + }) + }, + idNumberInput:function(e){ + var formData = this.data.formData; + formData.idNumber = e.detail.value; + this.setData({ + formData: formData + }) + }, + // 选择证件类型 + selectType:function(e){ + this.setData({ + selectIndex:e.detail.value + }) + // let data = []; + // for(let i=0;i{ + if(res.code==1){ + wx.showToast({ + title: '保存成功!', + icon:"success", + success:function(){ + util.back(); + } + }) + } + }) + }, + cancel:function(){ + util.back() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + } +}) \ No newline at end of file diff --git a/pages/old/linkman/add/index.json b/pages/old/linkman/add/index.json new file mode 100644 index 0000000..27b6d1f --- /dev/null +++ b/pages/old/linkman/add/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "title-header": "/pages/component/TitleHeader" + } +} \ No newline at end of file diff --git a/pages/old/linkman/add/index.wxml b/pages/old/linkman/add/index.wxml new file mode 100644 index 0000000..cf9960d --- /dev/null +++ b/pages/old/linkman/add/index.wxml @@ -0,0 +1,25 @@ + + + + + 姓名: + + + + 手机号: + + + + + + {{typeList[selectIndex]}} + + + + + + + 取消 + 确定 + + \ No newline at end of file diff --git a/pages/old/linkman/add/index.wxss b/pages/old/linkman/add/index.wxss new file mode 100644 index 0000000..3905c92 --- /dev/null +++ b/pages/old/linkman/add/index.wxss @@ -0,0 +1,64 @@ +/* pages/user/address/add/index.wxss */ +page { + background: #fff; +} +.input-item { + display: flex; + align-items: center; + height: 185rpx; + font-size: 49rpx; + font-weight: 500; + margin: 0 30rpx; + justify-content: space-between; + padding: 0 20rpx; + border-bottom: 1rpx solid #D8D8D8; +} +.input-item .weui-input { + flex: 1; +} +.input-item textarea.weui-input { + height: 120rpx; +} +.picker { + height: 80rpx; + background: #FFFFFF; + border: 1px solid #999999; + border-radius: 20rpx; + box-sizing: border-box; + text-align: center; + margin-right: 20rpx; +} +.picker text { + flex: 1; + text-align: center; + padding: 0 15rpx; +} +.picker .iconfont { + color: #0B898E; + width: 80rpx; + line-height: 80rpx; + border-left: 1px solid #999999; +} +.btns { + position: fixed; + left: 27rpx; + right: 27rpx; + bottom: 27rpx; + justify-content: space-between; + font-size: 49rpx; + font-weight: bold; +} +.btns view { + color: #0B898E; + border: 2rpx solid #0B898E; + background: white; + width: 333rpx; + box-sizing: border-box; + text-align: center; + border-radius: 20rpx; + line-height: 103rpx; +} +.btns view.active { + color: #fff; + background: #0B898E; +} \ No newline at end of file diff --git a/pages/old/linkman/index.js b/pages/old/linkman/index.js new file mode 100644 index 0000000..f5389e2 --- /dev/null +++ b/pages/old/linkman/index.js @@ -0,0 +1,185 @@ +// pages/user/address/index.js +import user from "../../../utils/https/user.js" +import util from "../../../utils/util.js" +let app = getApp() +Page({ + + /** + * 页面的初始数据 + */ + data: { + pageNo:1, + list:[], + isMore:true, + fromOrder:null, + safeBottom:app.globalData.safeBottom + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + fromOrder:options.from || null, + pid:options.pid || null, + sid:options.sid || null + }) + }, + // 如果是来自订单的点击选中联系人 + setOrderLinkman:function(e){ + console.log(this.data.fromOrder) + if(this.data.fromOrder=='order'){ + let pid = this.data.pid,sid = this.data.sid; + app.globalData.shoppingCart.map((item,index,arr)=>{ + if(item.baseInfo.id==pid && item.skuInfo.id==sid){ + // 只有当产品id和规格id一致的时候才把联系人赋值进去 + // 并且只有当这个联系人没有在选中的联系人中才需要赋值 + let index = item.linkman.findIndex((l)=>l.id==e.currentTarget.dataset.item.id); + if(item.productNum<=item.linkman.length && index==-1){ + item.linkman[item.linkman.length-1] = e.currentTarget.dataset.item + } + else if(index==-1){ + item.linkman.push(e.currentTarget.dataset.item) + } + } + }) + util.back() + } + else if(this.data.fromOrder=='CtripOrder'){ + // 携程下单来的 + app.globalData.product.linkman = e.currentTarget.dataset.item; + util.back(); + } + }, + getList: function () { + user.user_post("user/getContactOrConsignee", { + contactType:"CONTACT", + offset: this.data.list.length, + limit: 10 + }).then(res => { + let list = this.data.list.concat(res.data),isMore = true; + if(res.data.length<10){ + isMore = false; + } + this.setData({ + list: list, + isMore: isMore + }) + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + // 设为默认 + setDefault:function(e){ + let item = e.currentTarget.dataset.item; + if(item.is_default==1) return; + user.user_post("user/setDefaultContact",{contactId:item.id}).then(res=>{ + // 设置默认成功 + let list = this.data.list; + if(res.data){ + wx.showToast({ + title: '操作成功!', + icon:"success" + }); + list.map((i,index,arr)=>{ + if(i.id==item.id){ + i.is_default = 1; + } + else { + i.is_default = '0'; + } + }) + this.setData({ + list:list + }) + } + }) + }, + // 删除单个地址 + del: function (e) { + let that = this, id = e.currentTarget.dataset.id, index = e.currentTarget.dataset.index; + wx.showModal({ + title: '提示', + content: '确定删除吗?', + success: function (res) { + if (res.confirm) { + // 确定删除 + user.user_post("user/delContact", { contactId: id }).then(res => { + if (res.code==1) { + wx.showToast({ + title: '删除成功', + icon: 'success' + }) + let data = that.data.list; + data.splice(index, 1) + that.setData({ + list: data + }) + } + }) + } + } + }) + }, + add: function (e) { + console.log(e) + if (e.target.dataset.id) { + wx.navigateTo({ + url: './add/index?id=' + e.target.dataset.id + }) + } + else { + wx.navigateTo({ + url: './add/index?id=' + }) + } + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.setData({ + list:[], + pageNo:1, + isMore:true + }) + this.getList(); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + if(this.data.isMore){ + this.getList(); + } + } +}) \ No newline at end of file diff --git a/pages/old/linkman/index.json b/pages/old/linkman/index.json new file mode 100644 index 0000000..35cf02f --- /dev/null +++ b/pages/old/linkman/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "title":"/pages/component/TitleHeader" + } +} \ No newline at end of file diff --git a/pages/old/linkman/index.wxml b/pages/old/linkman/index.wxml new file mode 100644 index 0000000..b1aba9f --- /dev/null +++ b/pages/old/linkman/index.wxml @@ -0,0 +1,15 @@ + + + + 姓名:{{item.name}} + 手机号:{{item.tel}} + {{item.title}}:{{item.id_number}} + + + 默认出行人 + 编辑 + 删除 + + + +添加出行人 \ No newline at end of file diff --git a/pages/old/linkman/index.wxss b/pages/old/linkman/index.wxss new file mode 100644 index 0000000..811a181 --- /dev/null +++ b/pages/old/linkman/index.wxss @@ -0,0 +1,56 @@ +/* pages/old/linkman/index.wxss */ +.btn { + position: fixed; + left: 27rpx; + right: 27rpx; + width: 697rpx; + line-height: 107rpx; + background: #0B898E; + border-radius: 20rpx; + bottom: 27rpx; + text-align: center; + color: #fff; + font-size: 49rpx; + font-weight: 500; +} +.item { + color: #333333; + margin-bottom: 40rpx; + font-size: 49rpx; + font-weight: 500; + background: white; + padding: 0 27rpx; + line-height: 80rpx; + padding-top: 20rpx; +} +page { + background: #EDEDED; +} +.item .com-flex { + padding-left: 24rpx; + padding-right: 13rpx; + font-size: 44rpx; + border-top: 1px solid #D8D8D8; + height: 147rpx; + margin-top: 20rpx; +} +.item .com-flex .iconfont { + width: 53rpx; + line-height: 53rpx; + border-radius: 50%; + text-align: center; + margin-right: 20rpx; + overflow: hidden; +} +.item .com-flex .icon-quan { + color: #ccc; + background: #ccc; +} +.item .com-flex .icon-gou { + color: #0B898E; + font-size: 53rpx; +} +.item .com-flex .edit-btn { + color: #0B898E; + margin-left: 40rpx; +} \ No newline at end of file diff --git a/pages/old/nickname/index.js b/pages/old/nickname/index.js new file mode 100644 index 0000000..532d884 --- /dev/null +++ b/pages/old/nickname/index.js @@ -0,0 +1,103 @@ +// pages/old/nickname/index.js +import util from "../../../utils/util" +import userApi from "../../../utils/https/user" +Page({ + + /** + * 页面的初始数据 + */ + data: { + info:null + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + userApi.user_post("user/getMyInfo",{}).then(res=>{ + this.setData({ + info:res.data + }) + }) + }, + changeName:function(e){ + let info = this.data.info + info.nickname = e.detail.value + this.setData({ + info:info + }) + }, + submit:function(e){ + if(!this.data.info.nickname){ + wx.showToast({ + title: '请输入昵称', + icon: 'none' + }) + return; + } + userApi.user_post("user/changeNickname",{ + nickname: this.data.info.nickname + }).then(res=>{ + if(res.code==1){ + wx.showToast({ + title: '修改成功!', + icon:"success" + }) + setTimeout(()=>{ + wx.navigateBack({ + complete: (res) => {}, + }) + },1000) + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/old/nickname/index.json b/pages/old/nickname/index.json new file mode 100644 index 0000000..35cf02f --- /dev/null +++ b/pages/old/nickname/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "title":"/pages/component/TitleHeader" + } +} \ No newline at end of file diff --git a/pages/old/nickname/index.wxml b/pages/old/nickname/index.wxml new file mode 100644 index 0000000..6b86e38 --- /dev/null +++ b/pages/old/nickname/index.wxml @@ -0,0 +1,6 @@ + + + + + +保存 \ No newline at end of file diff --git a/pages/old/nickname/index.wxss b/pages/old/nickname/index.wxss new file mode 100644 index 0000000..36b6360 --- /dev/null +++ b/pages/old/nickname/index.wxss @@ -0,0 +1,25 @@ +/* pages/old/nickname/index.wxss */ +.input-box { + height: 187rpx; + margin: 0 30rpx; + border-bottom: 1px solid #D8D8D8; +} +.input-box input { + display: block; + width: 100%; + font-size: 49rpx; + color: #333333; + font-weight: bold; + flex: 1; +} +.btn { + width: 697rpx; + line-height: 107rpx; + background: #0B898E; + border-radius: 20rpx; + text-align: center; + color: #fff; + font-size: 49rpx; + font-weight: bold; + margin: 40rpx auto; +} \ No newline at end of file diff --git a/pages/old/profile/index.js b/pages/old/profile/index.js new file mode 100644 index 0000000..8774ede --- /dev/null +++ b/pages/old/profile/index.js @@ -0,0 +1,214 @@ +// pages/user/profile/index.js +let app = getApp(); +import util from "../../../utils/util" +import WeCropper from '../../../we-cropper/we-cropper.min.js'; +import userApi from "../../../utils/https/user" +let device = wx.getSystemInfoSync(),rect = wx.getMenuButtonBoundingClientRect(); // 获取设备信息 +const width = device.windowWidth // 示例为一个与屏幕等宽的正方形裁剪框 +let menuHeight = (rect.top - device.statusBarHeight) * 2 + rect.height + device.statusBarHeight; +let height = device.windowHeight - menuHeight; +Page({ + + /** + * 页面的初始数据 + */ + data: { + menuWidth:width - rect.right + rect.width + 6, + info:null, + today:"2020-10-11", + sexes:['男','女'], + birthday:"", + sexIndex:0, + cropperOpt: { + id: 'cropper', // 用于手势操作的canvas组件标识符 + targetId: 'targetCropper', // 用于用于生成截图的canvas组件标识符 + pixelRatio: device.pixelRatio, // 传入设备像素比 + width, // 画布宽度 + height:height, // 画布高度 + src: '', + scale: 2.5, // 最大缩放倍数 + zoom: 8, // 缩放系数 + cut: { + x: (width - 320) / 2, // 裁剪框x轴起点 + y: (height - 320) / 2, // 裁剪框y轴起点 + width: 320, // 裁剪框宽度 + height: 320 // 裁剪框高度 + } + }, + showCropper:false, + avatar:"" + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + let { + cropperOpt + } = this.data,that = this; + cropperOpt.height = device.screenHeight - menuHeight; + cropperOpt.cut.y = (height - 320) / 2; + console.log(cropperOpt,menuHeight,device) + let today = new Date(); + this.setData({ + today:util.formatDate(today), + cropperOpt:cropperOpt + }) + this.cropper = new WeCropper(cropperOpt); + }, + // 插件通过touchStart、touchMove、touchEnd方法来接收事件对象。 + touchStart(e) { + console.log(e) + this.cropper.touchStart(e) + }, + touchMove(e) { + this.cropper.touchMove(e) + }, + touchEnd(e) { + this.cropper.touchEnd(e) + }, + changeSex:function(e){ + + userApi.user_post("user/changeSex",{ + sex:Number(e.detail.value)+1 + }).then(res=>{ + if(res.code==1){ + this.setData({ + sexIndex:e.detail.value + }) + wx.showToast({ + title: '修改成功', + icon: 'success' + }) + } + }) + }, + bindDateChange:function(e){ + let birthday = e.detail.value; + userApi.user_post("user/changeBirthday",{ + birthday:birthday + }).then(res=>{ + if(res.code==1){ + this.setData({ + birthday:birthday + }) + wx.showToast({ + title: '修改成功', + icon: 'success' + }) + } + }) + }, + // 自定义裁剪页面的布局中,可以重新选择图片 + uploadTap() { + const self = this + wx.chooseImage({ + count: 1, // 默认9 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success(res) { + const src = res.tempFilePaths[0] + self.cropper.pushOrign(src) + self.setData({ + showCropper: true + }) + } + }) + }, + // 生成图片 + getCropperImage() { + var that = this; + wx.showLoading({ title: '加载中', mask: true }); + this.cropper.getCropperImage(tempFilePath => { + // tempFilePath 为裁剪后的图片临时路径 + console.log(tempFilePath) + if (tempFilePath) { + wx.uploadFile({ + url: 'https://api.cloud.sz-trip.com/api/pbservice.other/upload', //这里是上传的服务器地址 + filePath: tempFilePath, + header:{ + token: wx.getStorageSync('jstrip_token'), + }, + name: "file", + success: function (res) { + console.log(res) + var res = JSON.parse(res.data); + let avatar = res.data.url; + userApi.user_post("user/changeAvatar",{ + avatarUrl:avatar + }).then(res=>{ + if(res.code==1){ + wx.hideLoading(); + that.setData({ + showCropper: false, + avatar: avatar + }) + } + }) + + }, + fail:function(res){ + wx.hideLoading(); + console.log('err',res) + } + }) + // 拿到裁剪后的图片路径的操作 + } else { + console.log('获取图片地址失败,请稍后重试') + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + userApi.user_post("user/getMyInfo",{}).then(res=>{ + this.setData({ + info:res.data, + avatar:res.data.avatar, + birthday:res.data.birthday + }) + if(res.data.gender==2){ + this.setData({ + sexIndex:1 + }) + } + }) + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + } +}) \ No newline at end of file diff --git a/pages/old/profile/index.json b/pages/old/profile/index.json new file mode 100644 index 0000000..35cf02f --- /dev/null +++ b/pages/old/profile/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "title":"/pages/component/TitleHeader" + } +} \ No newline at end of file diff --git a/pages/old/profile/index.wxml b/pages/old/profile/index.wxml new file mode 100644 index 0000000..847c008 --- /dev/null +++ b/pages/old/profile/index.wxml @@ -0,0 +1,20 @@ + + + <view wx:if="{{showCropper}}" bindtap="getCropperImage" class="submit-upload" style="right:{{menuWidth}}px">完成</view> + + + 头像 + + + + + + + 昵称 + {{info.nickname}} + + + +