作者 王军

套餐

... ... @@ -33,7 +33,47 @@ App({
}
})
},
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
//init
let that = this;
let postData = data;
let baseUrl = 'http://mite.w.brotop.cn';
//网络请求
let header = {
// 'XX-Device-Type': 'wxapp',
'token': wx.getStorageSync("token") || ''
}
header = Object.assign(header, headerParams)
//网络请求
wx.request({
url: baseUrl + url,
data: postData,
method: headerParams,
header: header,
success: function (res) { //返回取得的数据
if (res.data.code == '1') {
resolve(res.data.data);
} else if (res.data.code == '201') {
resolve(res.data);
} else {
reject(res)
}
},
fail: function (e) {
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
},
complete: function () {
wx.hideNavigationBarLoading()
},
})
});
return promise;
},
globalData: {
userInfo: null
userInfo: null,
}
})
\ No newline at end of file
... ...
... ... @@ -8,11 +8,11 @@
"pages/serviceexperience/serviceexperience",
"pages/serviceintro/serviceintro",
"pages/companyintro/companyintro",
"pages/myguanjia/myguanjia",
"pages/index/index",
"pages/logs/logs"
"pages/logs/logs",
"pages/star/star",
"pages/register/register"
],
"window": {
"backgroundTextStyle": "light",
... ...
// pages/companyintro/companyintro.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
image:"",
content:"",
},
// 获取公司详情
getCompanyDetail(){
let t = this;
let url = "/api/index/introduceDetail";
app.post(url)
.then(res=>{
t.setData({
image: res.image,
content:res.content
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 获取公司详情
this.getCompanyDetail()
},
/**
... ...
<view class="top">
<image src="/img/headimg.png"></image>
<view class="topimg">
<image src="/img/banner.png"></image>
<image src="{{image}}"></image>
</view>
</view>
<view class="textbox">
<view class="textboxword">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar sic tempor. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus pronin sapien nunc accuan eget.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar sic tempor. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus pronin sapien nunc accuan eget.
</view>
<view class="textboximg">
<image src="/img/people.png"></image>
</view>
<rich-text class="textboxword" nodes="{{content}}"></rich-text>
</view>
\ No newline at end of file
... ...
// pages/homeindex/homeindex.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
imgUrls: [
'/img/banner.png',
'/img/banner.png',
'/img/banner.png',
'/img/banner.png'
],
imgUrls: [],
indicatorDots: false,
autoplay: false,
interval: 2000,
duration: 1000,
currentSwiper: 0,
currentpage:1
currentpage:1,
// 公司简介
companyImg:"",
// 服务介绍
introImg:"",
// 服务体验
experImg:"",
// 个人中心
personalImg:"",
// 会员注册
registerImg:"",
// 一键预约
reservaImg:"",
isVip:"",// 是否为vip 0:否 1:是
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getPersonMsg();
// this.setData({
// isVip:wx.getStorageSync("is_vip")
// })
// 获取首页信息
this.getIndexMsg();
},
// 获取个人信息
getPersonMsg(){
let url = "/api/user/info";
app.post(url)
.then(res=>{
this.setData({
isVip:res.is_vip
})
wx.setStorageSync("is_vip",res.is_vip)
})
},
// 获取首页数据
getIndexMsg(){
console.log(111)
let t = this;
let url = "/api/index/index";
app.post(url)
.then((res)=>{
t.setData({
imgUrls:res.banner,
companyImg: res.thumbnail.introduce,
introImg: res.thumbnail.service,
experImg: res.thumbnail.experience,
personalImg: res.thumbnail.center,
registerImg: res.thumbnail.register,
reservaImg: res.thumbnail.reserve
})
})
},
// 公司简介
company(){
wx.navigateTo({
... ... @@ -46,14 +88,14 @@ Page({
url: '/pages/serviceexperience/serviceexperience',
})
},
// 会员注册
toRegister(){},
// 会员中心
vipmember(){
wx.navigateTo({
url: '/pages/membercenter/membercenter',
})
},
swiperChange: function (e) {
this.setData({
currentSwiper: e.detail.current,
... ...
... ... @@ -10,16 +10,10 @@
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" class="swiper_item_img" bindchange="swiperChange">
<block wx:for="{{imgUrls}}" wx:key="doct">
<swiper-item>
<image src="{{item}}" data-index='{{index}}' class="slide-image" bindtap='viewImg' width="355" height="150" />
<image src="{{item.image}}" data-index='{{index}}' class="slide-image" bindtap='viewImg' width="355" height="150" />
</swiper-item>
</block>
</swiper>
<!-- <view class="dots">
<block wx:for="{{imgUrls}}" wx:key="">
<view class="dot{{index == currentSwiper ? ' active' : ''}}"></view>
</block>
</view> -->
<view class="swiperdot">{{currentpage}}/{{imgUrls.length}}</view>
</view>
... ... @@ -31,21 +25,18 @@
<view class="boximg">
<view class="topbox">
<view class="topboxleft" bindtap="company">
<image src="/img/company.png"></image>
<image src="{{companyImg}}"></image>
<view class="textbox">
<view class="textboxtop">Company profile</view>
<view class="textboxbottom">公司简介</view>
</view>
<view class="yourow">
<image src="/img/row.png"></image>
</view>
</view>
<view class="topboxright" bindtap="serviceinto">
<image src="/img/intro.png"></image>
<view class="topboxright_t" bindtap="serviceinto">
<image src="{{introImg}}"></image>
<view class="servicetext">
<view class="serviceword">Service</view>
<view class="serviceword">introduction</view>
... ... @@ -59,8 +50,7 @@
<view class="topbox xiabox">
<view class="topboxright" bindtap="serviceexperience">
<image src="/img/fuwu.png"></image>
<image src="{{experImg}}"></image>
<view class="servicetext">
<view class="serviceword">Service</view>
<view class="serviceword">experience</view>
... ... @@ -70,15 +60,34 @@
<image src="/img/row.png"></image>
</view>
</view>
<view class="topboxleft" bindtap="vipmember">
<image src="/img/member.png"></image>
<view class="topboxright" bindtap="toRegister" wx:if="{{isVip == 0}}">
<image src="{{registerImg}}"></image>
<view class="servicetext">
<view class="serviceword">Member</view>
<view class="serviceword">registration</view>
<view class="serviceword">会员注册</view>
</view>
<view class="yourow">
<image src="/img/row.png"></image>
</view>
</view>
<view class="topboxright" bindtap="vipmember" wx:if="{{isVip == 0}}">
<image src="{{personalImg}}"></image>
<view class="servicetext">
<view class="serviceword">Personal</view>
<view class="serviceword">center</view>
<view class="serviceword">个人中心</view>
</view>
<view class="yourow">
<image src="/img/row.png"></image>
</view>
</view>
<view class="topboxleft" bindtap="vipmember" wx:if="{{isVip == 1}}">
<image src="{{reservaImg}}"></image>
<view class="textbox">
<view class="textboxtop">Member Center</view>
<view class="textboxtop">Immediately reservation</view>
<view class="textboxbottom">会员中心</view>
</view>
<view class="yourow">
<image src="/img/row.png"></image>
</view>
... ...
... ... @@ -125,16 +125,22 @@ image {
font-size: 0;
position: relative
}
.topboxright{
/* 服务介绍 */
.topboxright_t{
width:244rpx;
height:244rpx;
font-size:0;
position: relative
}
.topboxright{
width:214rpx;
height:214rpx;
font-size:0;
position: relative
}
.boximg{
padding: 34rpx 32rpx;
box-sizing: border-box
}
.textbox{
position:absolute;
... ... @@ -144,8 +150,8 @@ image {
}
.servicetext{
position: absolute;
top:42rpx;
left:24rpx;
top:20rpx;
left:20rpx;
}
.textboxtop{
color:#FFFFFF;
... ... @@ -160,7 +166,7 @@ image {
}
.serviceword{
color:#FFFFFF;
font-size: 32rpx;
font-size: 30rpx;
font-weight: bold;
margin-bottom:10rpx;
}
... ...
... ... @@ -6,14 +6,21 @@ Page({
*/
data: {
yuyuecancel:false,
yuyuesuccess:false
yuyuesuccess:false,
nickName:"",
avatar:"",
token:"",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
token:wx.getStorageSync("token"),
avatar:wx.getStorageSync("avatarUrl"),
nickName:wx.getStorageSync("nickName")
})
},
cancelyuyue(){
this.setData({
... ...
... ... @@ -3,9 +3,9 @@
<view class="login">
<view class="loginleft">
<image src="/img/morenhead.png"></image>
<image src="{{avatar}}"></image>
</view>
<view class="loginright">登录</view>
<view class="loginright">{{nickName}}</view>
</view>
<view class="servicebox">
... ... @@ -65,7 +65,7 @@
<view class="queren">一键预约</view>
<!-- <view class="queren">一键预约</view> -->
</view>
</view>
... ...
... ... @@ -126,6 +126,9 @@ image {
font-size: 0;
border-radius: 50%
}
.loginleft image{
border-radius: 50%
}
.loginright{
color:#FFFFFF;
font-size: 36rpx;
... ...
// pages/myservice/myservice.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
list:[],
page:1,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getMyService()
},
// 获取我的服务
getMyService(){
let t = this;
let url = "/api/user/myService";
let params = {
page:t.data.page
};
app.post(url,params)
.then(res=>{
t.setData({
list:res.data
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
... ... @@ -2,99 +2,29 @@
<image src="/img/headimg.png"></image>
</view>
<view class="servicebox">
<view class="serviceboxitem">
<view class="serviceitemtop">2019-10-10 20:30:30</view>
<view class="servicebox">
<view class="serviceboxitem" wx:for="{{list}}" wx:key="{{index}}">
<view class="serviceitemtop">{{item.service_time}}</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务单号:</view>
<view class="serviceitemlistright">L548796631457</view>
<view class="serviceitemlistright">{{item.order_sn}}</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务项目:</view>
<view class="serviceitemlistright">别墅除螨</view>
<view class="serviceitemlistright">{{item.service_content}}</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务人员:</view>
<view class="serviceitemlistright">李功虎师傅</view>
<view class="serviceitemlistright">{{item.service_name}}</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务评价:</view>
<view class="serviceitemlistright">A</view>
<view class="serviceitemlistright">{{item.assess}}</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">备注:</view>
<view class="serviceitemlistright">xxxxxxxx</view>
<view class="serviceitemlistright">{{item.mark}}</view>
</view>
</view>
<view class="serviceboxitem">
<view class="serviceitemtop">2019-10-10 20:30:30</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务单号:</view>
<view class="serviceitemlistright">L548796631457</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务项目:</view>
<view class="serviceitemlistright">别墅除螨</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务人员:</view>
<view class="serviceitemlistright">李功虎师傅</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务评价:</view>
<view class="serviceitemlistright">A</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">备注:</view>
<view class="serviceitemlistright">xxxxxxxx</view>
</view>
</view>
<view class="serviceboxitem">
<view class="serviceitemtop">2019-10-10 20:30:30</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务单号:</view>
<view class="serviceitemlistright">L548796631457</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务项目:</view>
<view class="serviceitemlistright">别墅除螨</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务人员:</view>
<view class="serviceitemlistright">李功虎师傅</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务评价:</view>
<view class="serviceitemlistright">A</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">备注:</view>
<view class="serviceitemlistright">xxxxxxxx</view>
</view>
</view>
<view class="serviceboxitem">
<view class="serviceitemtop">2019-10-10 20:30:30</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务单号:</view>
<view class="serviceitemlistright">L548796631457</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务项目:</view>
<view class="serviceitemlistright">别墅除螨</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务人员:</view>
<view class="serviceitemlistright">李功虎师傅</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">服务评价:</view>
<view class="serviceitemlistright">A</view>
</view>
<view class="serviceitemlist">
<view class="serviceitemlistleft">备注:</view>
<view class="serviceitemlistright">xxxxxxxx</view>
</view>
</view>
</view>
\ No newline at end of file
</view>
\ No newline at end of file
... ...
// pages/mytaocan/mytaocan.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
name:"",
phone:"",
address:"",
content:"",
tableList:[],
page:1,
totalPage:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getMyorder();
},
// 获取我的套餐
getMyorder(){
let t = this;
let url = "/api/user/myOrder";
let params = {
page:t.data.page
};
app.post(url,params)
.then(res=>{
t.setData({
name:res.user.user_name,
phone:res.user.mobile,
address:res.user.province+res.user.city+res.user.district,
content:res.user.mark,
tableList:res.data
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
... ... @@ -8,7 +8,7 @@
<image src="/img/ren.png"></image>
</view>
<view class="taocanboxitemright">李宝杰</view>
<view class="taocanboxitemright">{{name}}</view>
</view>
<view class="taocanboxitem">
... ... @@ -16,14 +16,14 @@
<image src="/img/bigphone.png"></image>
</view>
<view class="taocanboxitemright">15888888888</view>
<view class="taocanboxitemright">{{phone}}</view>
</view>
<view class="taocanboxitem">
<view class="taocanboxitemleft">
<image src="/img/house.png"></image>
</view>
<view class="taocanboxitemright">天津市西青区南山公寓4号楼5门311</view>
<view class="taocanboxitemright">{{address}}</view>
</view>
<view class="taocanboxitem">
... ... @@ -31,7 +31,7 @@
<image src="/img/mark.png"></image>
</view>
<view class="taocanboxitemright">备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注</view>
<view class="taocanboxitemright">{{content}}</view>
</view>
... ... @@ -49,35 +49,11 @@
</view>
<view class="orderbox">
<view class="orderboxitem">
<view class="boxitemleft">No.5565890</view>
<view class="boxitemmiddle">内容内容内容内容 内容内容内容内容
<view class="orderboxitem" wx:for="{{tableList}}" wx:key="index">
<view class="boxitemleft">{{item.order_sn}}</view>
<view class="boxitemmiddle">{{item.content}}
</view>
<view class="boxitemright">3</view>
</view>
<view class="orderboxitem">
<view class="boxitemleft">No.5565890</view>
<view class="boxitemmiddle">内容内容内容内容 内容内容内容内容
</view>
<view class="boxitemright">3</view>
</view>
<view class="orderboxitem">
<view class="boxitemleft">No.5565890</view>
<view class="boxitemmiddle">内容内容内容内容 内容内容内容内容
</view>
<view class="boxitemright">3</view>
</view>
<view class="orderboxitem">
<view class="boxitemleft">No.5565890</view>
<view class="boxitemmiddle">内容内容内容内容 内容内容内容内容
</view>
<view class="boxitemright">3</view>
</view>
<view class="orderboxitem">
<view class="boxitemleft">No.5565890</view>
<view class="boxitemmiddle">内容内容内容内容 内容内容内容内容
</view>
<view class="boxitemright">3</view>
<view class="boxitemright">{{item.total_num}}</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
// pages/register/register.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
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
/* pages/register/register.wxss */
\ No newline at end of file
... ...
// pages/serviceexperience/serviceexperience.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
region: ['北京市', '北京市', '东城区'],
place:'请选择省市区'
region: [],
place: '请选择省市区',
content: "",
name: "",
phone: "",
address: "",
token: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
this.setData({
token: wx.getStorageSync("token")
})
// 获取服务介绍详情
this.getServeiceDetail();
},
// 获取服务介绍详情
getServeiceDetail() {
let t = this;
let url = "/api/index/experienceDetail";
app.post(url)
.then(res => {
t.setData({
content: res.content
})
})
},
// 获取姓名
getName(e) {
this.setData({
name: e.detail.value
})
},
// 获取手机号
getPhone(e) {
this.setData({
phone: e.detail.value
})
},
// 获取详细地址
getAddress(e) {
this.setData({
address: e.detail.value
})
},
// 免费预约
submit() {
// 判断是否登录
let t = this;
if (t.data.token) {
if (t.data.region.length > 0 && t.data.name && t.data.phone && t.data.address) {
let url = "/api/user/freeBook";
let params = {
user_name: t.data.name,
mobile: t.data.phone,
address: t.data.address,
province: t.data.region[0],
city: t.data.region[1],
district: t.data.region[2]
};
app.post(url, params,"post")
.then(res => {
wx.showToast({
title: '预约成功',
icon:"success",
duration:1500,
})
setTimeout(function(){
wx.navigateBack({
delta:1
})
},1500)
})
} else {
wx.showToast({
title: '请输入完整信息',
icon: "none"
})
}
}else{
// 未登录
wx.navigateTo({
url: '/pages/star/star',
})
}
},
bindRegionChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
bindRegionChange: function(e) {
this.setData({
region: e.detail.value,
place:e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
place: e.detail.value[0] + '、' + e.detail.value[1] + '、' + e.detail.value[2]
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
... ... @@ -6,8 +6,7 @@
</view>
<view class="servicetext">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proingravida dolor sit amet lacus accumsan et viverra commodo. Proin sodales pulvinar sic tempor. Sociis natoque bibendum laoreet. Proin gravida dolor sit amet lacus
accumsan et viverra justo commodo.
<rich-text nodes="{{content}}"></rich-text>
</view>
<view class="servicebox">
... ... @@ -19,7 +18,7 @@
<image src="/img/renyuan.png"></image>
</view>
<view class="servicelistright">
<input placeholder='请输入您的姓名' placeholder-class='entertext' />
<input placeholder='请输入您的姓名' value="{{name}}" bindinput='getName' placeholder-class='entertext' />
</view>
</view>
<view class="servicelistitem">
... ... @@ -27,15 +26,11 @@
<image src="/img/shouji.png"></image>
</view>
<view class="servicelistright">
<input placeholder='请输入您的手机号' placeholder-class='entertext' />
<input placeholder='请输入您的手机号' maxlength='11' value="{{phone}}" bindinput='getPhone' placeholder-class='entertext' />
</view>
</view>
<picker mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}">
<!-- <view class="picker">
当前选择:{{region[0]}},{{region[1]}},{{region[2]}}
</view> -->
<view class="servicelistitem">
<view class="servicelsitleft">
<image src="/img/map.png"></image>
... ... @@ -56,11 +51,11 @@
<image src="/img/index.png"></image>
</view>
<view class="servicelistright">
<input placeholder='请输入详细地址' placeholder-class='entertext' />
<input placeholder='请输入详细地址' value="{{address}}" bindinput='getAddress' placeholder-class='entertext' />
</view>
</view>
<view class="queren">确认</view>
<view class="queren" bindtap='submit'>确认</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
// pages/serviceintro/serviceintro.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
image: "",
content: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
// 获取服务介绍
this.getIntro();
},
// 获取服务介绍
getIntro() {
let t = this;
let url = "/api/index/serviceDetail";
app.post(url)
.then(res => {
t.setData({
image: res.image,
content: res.content
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
<view class="top">
<image src="/img/headimg.png"></image>
<view class="topimg">
<image src="/img/banner.png"></image>
<image src="{{image}}"></image>
</view>
</view>
<view class="textbox">
<view class="textboxword">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar sic tempor. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus pronin sapien nunc accuan eget.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar sic tempor. Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus pronin sapien nunc accuan eget.
</view>
<view class="textboximg">
<image src="/img/people.png"></image>
</view>
<rich-text class="textboxword" nodes="{{content}}"></rich-text>
</view>
\ No newline at end of file
... ...
// pages/star/star.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
// 用来换取token的四个必传参数
// code换取的'session_key'和'openid'
code:"",
nickName:"",
avatar:"",
},
// 获取用户信息(授权)
star(e) {
// console.log(e); // 此处会返回换取token必须的'encryptedData'和'iv'两个参数,
// this.setData({
// encryptedData: e.detail.encryptedData,
// iv: e.detail.iv
// });
this.setData({
nickName: e.detail.userInfo.nickName,
avatar: e.detail.userInfo.avatarUrl
})
wx.setStorageSync('avatarUrl', e.detail.userInfo.avatarUrl);
wx.setStorageSync('nickName', e.detail.userInfo.nickName);
// 授权之后需要调取登录的方法
this.login()
},
// 登录
login() {
let t = this;
// let url = "用{'session_key','openid','encryptedData','iv'}换取token的接口";
let url = "/api/user/login";
// 此处是获取token需要传递的参数
let params = {
code:t.data.code,
nickname:t.data.nickName,
avatar:t.data.avatar
}
app.post(url, params,"post").then(r => {
console.log(r) // 此处会返回一个token => (小程序登录的唯一标识)
// 需要将token存在缓存中,(以备需要);
wx.setStorageSync("token", r.token) // =>存入的是一个键值
// 获取个人信息
let url = "/api/user/info";
app.post(url)
.then(res=>{
wx.setStorageSync("token", res.token);
wx.setStorageSync("is_vip", res.is_vip) //是否为vip
// 之后跳转页面/执行方法
wx.redirectTo({
url: '/pages/homeindex/homeindex',
})
})
}).catch(err => {
console.log(err)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
wx.login({
success: (res) => {
this.setData({
code:res.code
})
console.log(res, "此处会返回一个code");
// var url = "用code换取'session_key'和'openid'的接口";
// let url = "api/user/getSessionKey";
// var params = {
// code: res.code //这是wx.login的方法返回的code
// };
// app.post(url, params).then(r => {
// console.log(r) //此处会返回用code换取的'session_key'和'openid'
// // 之后将他们赋值到data中,方便调用
// this.setData({
// session_key: r.session_key,
// openid: r.openid
// })
// }).catch(err => {
// console.log(err)
// })
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
{
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "启动",
"backgroundColor": "#fff",
"backgroundTextStyle": "light",
"enablePullDownRefresh": false
}
\ No newline at end of file
... ...
<!-- 获取用户信息 -->
<view class='contant'>
<view class='img'>
<image src='../../images/poster.png'></image>
</view>
<view class='button'>
<button class="button_top" open-type="getUserInfo" bindgetuserinfo="star">授权登录</button>
<view class="button_bot" bindtap="noLogin" >暂不授权</view>
</view>
</view>
\ No newline at end of file
... ...
/* page/Modify/modify.wxss */
.contant {
width: 100%;
padding: 100rpx 50rpx 0;
box-sizing: border-box;
}
.img {
width: 100%;
height: 1000rpx;
font-size: 0;
}
.img image {
width: 100%;
height: 100%;
}
.button {
width: 100%;
padding: 0 60rpx;
box-sizing: border-box;
position: fixed;
bottom: 200rpx;
left: 50%;
transform: translate(-50%, 0);
}
.button_top {
width: 100%;
background:rgba(39,53,116,1);
box-shadow:0px 6px 6px rgba(0,0,0,0.16);
color: rgba(255, 255, 255, 1);
margin-bottom:20rpx
}
.button_bot{
text-align: center
}
... ...
... ... @@ -4,7 +4,7 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
... ... @@ -13,7 +13,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.10.0",
"appid": "wx1f51f42105b63343",
"appid": "wxf6853676224588fe",
"projectname": "chuman",
"debugOptions": {
"hidedInDevtools": []
... ... @@ -39,12 +39,54 @@
"list": []
},
"miniprogram": {
"current": 0,
"current": 6,
"list": [
{
"id": -1,
"name": "会员中心",
"pathName": "pages/membercenter/membercenter",
"query": "",
"scene": null
},
{
"id": -1,
"name": "公司简介",
"pathName": "pages/companyintro/companyintro",
"query": "",
"scene": null
},
{
"id": -1,
"name": "服务体验",
"pathName": "pages/serviceexperience/serviceexperience",
"query": "",
"scene": null
},
{
"id": -1,
"name": "授权",
"pathName": "pages/star/star",
"query": "",
"scene": null
},
{
"id": -1,
"name": "会员中心",
"pathName": "pages/membercenter/membercenter",
"query": "",
"scene": null
},
{
"id": -1,
"name": "我的套餐",
"pathName": "pages/mytaocan/mytaocan",
"query": "",
"scene": null
},
{
"id": -1,
"name": "我的服务",
"pathName": "pages/myservice/myservice",
"scene": null
}
]
... ...