Browse Source

瑞梦思

master
杨豪 3 years ago
commit
b043c0b671
  1. 31
      .eslintrc.js
  2. 59
      app.js
  3. 19
      app.json
  4. 95
      app.wxss
  5. BIN
      images/chongsu.png
  6. BIN
      images/company-bg.png
  7. BIN
      images/company-info.png
  8. BIN
      images/home.png
  9. BIN
      images/index-top.png
  10. BIN
      images/jixiang.png
  11. BIN
      images/list.png
  12. BIN
      images/logo.png
  13. BIN
      images/share.png
  14. BIN
      images/tip-icon.png
  15. BIN
      images/title1.png
  16. BIN
      images/title2.png
  17. 70
      pages/companyInfo/index.js
  18. 4
      pages/companyInfo/index.json
  19. 22
      pages/companyInfo/index.wxml
  20. 48
      pages/companyInfo/index.wxss
  21. 75
      pages/goodsDetail/index.js
  22. 4
      pages/goodsDetail/index.json
  23. 55
      pages/goodsDetail/index.wxml
  24. 121
      pages/goodsDetail/index.wxss
  25. 70
      pages/goodsList/index.js
  26. 4
      pages/goodsList/index.json
  27. 16
      pages/goodsList/index.wxml
  28. 48
      pages/goodsList/index.wxss
  29. 89
      pages/home/index.js
  30. 4
      pages/home/index.json
  31. 51
      pages/home/index.wxml
  32. 124
      pages/home/index.wxss
  33. 50
      pages/index/index.js
  34. 3
      pages/index/index.json
  35. 23
      pages/index/index.wxml
  36. 19
      pages/index/index.wxss
  37. 167
      pages/login/index.js
  38. 4
      pages/login/index.json
  39. 17
      pages/login/index.wxml
  40. 46
      pages/login/index.wxss
  41. 74
      project.config.json
  42. 7
      sitemap.json
  43. 19
      utils/util.js

31
.eslintrc.js

@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

59
app.js

@ -0,0 +1,59 @@
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
},
login(loginInfo){
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
http(methods,url,params){
var header = {
'content-type': 'application/json',
'Authorization' : wx.getStorageSync('token') || ''
};
return new Promise((resolve,reject)=>{
wx.showLoading({
title: '正在加载中...',
})
wx.request({
url: this.globalData.baseUrl + url,
method: methods,
header: header,
data: params || {},
success: res=> {
wx.hideLoading();
if(!res.data.success && res.data.status == 401){
// console.log('登陆失效')
wx.navigateTo({
url: '/pages/login/index',
})
}
resolve(res);
},
fail: err=> {
wx.hideLoading();
wx.showToast({
title: '服务器错误,请稍后再试!',
icon : 'none'
})
reject(err)
}
})
})
},
globalData: {
baseURL : 'http://192.168.0.114:8092/api/',
// baseURL : 'https://cloud.api.cyjyyjy.com/api/',
}
})

19
app.json

@ -0,0 +1,19 @@
{
"pages":[
"pages/home/index",
"pages/goodsList/index",
"pages/login/index",
"pages/goodsDetail/index",
"pages/companyInfo/index",
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

95
app.wxss

@ -0,0 +1,95 @@
view,
scroll-view,
swiper,
button,
input,
textarea,
label,
navigator,
image {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
image{
/* border-radius: 8rpx; */
}
/* layout */
.acea-row-nowrap {
display: flex;
/* 辅助类 */
}
.acea-row {
display: flex;
flex-wrap: wrap;
/* 辅助类 */
}
.acea-row.row-middle,.acea-row-nowrap.row-middle{
align-items: center;
}
.acea-row.row-top,.acea-row-nowrap.row-top {
align-items: flex-start;
}
.acea-row.row-bottom {
align-items: flex-end;
}
.acea-row.row-center,.acea-row-nowrap.row-center {
justify-content: center;
}
.acea-row.row-right,.acea-row-nowrap.row-right {
justify-content: flex-end;
}
.acea-row.row-left,.acea-row-nowrap.row-left {
justify-content: flex-start;
}
.acea-row.row-between,.acea-row-nowrap.row-between {
justify-content: space-between;
}
.acea-row.row-around, .acea-row-nowrap.row-around{
justify-content: space-around;
}
.acea-row.row-column-around,.acea-row-nowrap.row-column-around {
flex-direction: column;
justify-content: space-around;
}
.acea-row.row-column {
flex-direction: column;
}
.acea-row.row-column-between,.acea-row-nowrap.row-column-between {
flex-direction: column;
justify-content: space-between;
}
/* 上下左右垂直居中 */
.acea-row.row-center-wrapper,.acea-row-nowrap.row-center-wrapper {
align-items: center;
justify-content: center;
}
/* 上下两边居中对齐 */
.acea-row.row-between-wrapper,.acea-row-nowrap.row-between-wrapper {
align-items: center;
justify-content: space-between;
}
.line1{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
width: 100%;
}
.line2{
word-break:break-all;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
}
.submit-btn{
width: 318rpx;
height: 68rpx;
background: linear-gradient(274deg, #EE7F7B 0%, #EB5750 100%);
border-radius: 34rpx;
text-align: center;
line-height: 68rpx;
font-size: 36rpx;
color: #fff;
font-weight: 500;
margin: 60rpx auto;
}

BIN
images/chongsu.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

BIN
images/company-bg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
images/company-info.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

BIN
images/home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

BIN
images/index-top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 KiB

BIN
images/jixiang.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 KiB

BIN
images/list.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

BIN
images/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/share.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

BIN
images/tip-icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

BIN
images/title1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/title2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

70
pages/companyInfo/index.js

@ -0,0 +1,70 @@
// pages/companyInfo/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
toList(){
wx.navigateTo({
url: '/pages/goodsList/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

4
pages/companyInfo/index.json

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "公司信息"
}

22
pages/companyInfo/index.wxml

@ -0,0 +1,22 @@
<!--pages/companyInfo/index.wxml-->
<view class="companyInfo-page">
<view class="top-bg"><image src="../../images/company-info.png"></image></view>
<view class="content-box">
<view class="title-box">
<image src="../../images/title1.png"></image>
</view>
<view class="introduse-box">
<text>深圳市瑞梦思时代科技有限公司,瑞蓢国际集团旗下全资子公司,以能量家居系统、智慧健康睡眠生态系统为主打的核心品牌。当前旗下产品包括“重塑本元”、“吉祥卧”床垫,“少年强”青少年床垫,旅行垫,魔术减负能量背包等。\n</text>
<text>瑞梦思以“专注每一天,健康每一夜”为目标,为人们研发贯穿生活各方面的能量家居产品,让每个家庭,每个人都能从源头开始防患于未然,远离亚健康,享受真正健康轻松的幸福生活。</text>
</view>
<view class="title-box">
<image src="../../images/title2.png"></image>
</view>
<view class="list-box acea-row row-between">
<view class="item"><image src="../../images/jixiang.png" mode="aspectFill"></image></view>
<view class="item"><image src="../../images/jixiang.png" mode="aspectFill"></image></view>
<view class="item"><image src="../../images/jixiang.png" mode="aspectFill"></image></view>
</view>
</view>
<view class="submit-btn" bindtap="toList">更多商品</view>
</view>

48
pages/companyInfo/index.wxss

@ -0,0 +1,48 @@
/* pages/companyInfo/index.wxss */
.companyInfo-page{
width: 100%;
}
.top-bg{
width: 100%;
height: 578rpx;
}
.top-bg image{
width: 100%;
height: 100%;
}
.content-box{
width: 100%;
padding: 0 40rpx;
}
.title-box{
width: 100%;
height: 92rpx;
}
.title-box image{
width: 100%;
height: 100%;
}
.introduse-box{
padding: 12rpx 0;
color: #0B204C;
font-size: 24rpx;
line-height: 34rpx;
font-weight: 500;
text-indent: 1em;
}
.list-box{
width: 100%;
margin-top: 32rpx;
}
.item{
width: 200rpx;
height: 152rpx;
}
.item image{
width: 100%;
height: 100%;
border-radius: 8rpx;
}
.submit-btn{
margin: 60rpx auto;
}

75
pages/goodsDetail/index.js

@ -0,0 +1,75 @@
// pages/goodsDetail/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
toHome(){
wx.navigateTo({
url: '/pages/home/index',
})
},
toList(){
wx.navigateTo({
url: '/pages/goodsList/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

4
pages/goodsDetail/index.json

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "商品详情"
}

55
pages/goodsDetail/index.wxml

@ -0,0 +1,55 @@
<!--pages/goodsDetail/index.wxml-->
<view class="detail-page">
<view class="swiper-box">
<swiper>
<block>
<swiper-item>
<view class="swiper-item">
<image src="../../images/jixiang.png" mode="widthFix"></image>
</view>
</swiper-item>
</block>
</swiper>
</view>
<view class="goods-info-box acea-row row-between">
<view class="info-l-box">
<view class="name line1">瑞梦思·布胡斯智能床垫</view>
<view class="price"><text class="fz20">¥</text>129000-289000</view>
<view class="old-price">原价:¥<text class="row-line">99999</text></view>
</view>
<view class="info-r-box">
<view>销量:999+</view>
<button open-type="share" class="share-btn acea-row row-center-wrapper">
<image src="../../images/share.png"></image>
<text>分享</text>
</button>
</view>
</view>
<view class="title-box acea-row row-center row-middle">
<view class="row-line"></view>
<view class="title">产商品情</view>
<view class="row-line"></view>
</view>
<view class="produce-detail">
<image src="../../images/jixiang.png" mode="widthFix"></image>
<image src="../../images/jixiang.png" mode="widthFix"></image>
<image src="../../images/chongsu.png" mode="widthFix"></image>
<image src="../../images/chongsu.png" mode="widthFix"></image>
</view>
<view class="footer-box acea-row row-between-wrapper">
<view class="icons-box acea-row">
<view class="home" bindtap="toHome">
<image src="../../images/home.png"></image>
<text>首页</text>
</view>
<view class="home" bindtap="toList">
<image src="../../images/list.png"></image>
<text>商品列表</text>
</view>
</view>
<view class="submit-btn">立即咨询</view>
</view>
<view class="mask-box">
</view>
</view>

121
pages/goodsDetail/index.wxss

@ -0,0 +1,121 @@
/* pages/goodsDetail/index.wxss */
.detail-page{
min-height: 100vh;
padding-bottom: 180rpx;
background: #F7F7F7;
}
.swiper-box{
width: 100%;
height: 500rpx;
}
.swiper-box swiper{
width: 100%;
height: 100%;
}
.swiper-item image{
width: 100%;
height: 100%;
}
.goods-info-box{
width: 670rpx;
height: 216rpx;
background: #fff;
border-radius: 12rpx;
margin: 32rpx auto;
padding: 24rpx 0 24rpx 24rpx;
}
.info-l-box{
width: 420rpx;
}
.info-l-box .name{
color: #202020;
font-size: 32rpx;
font-weight: 500;
}
.price{
font-size: 52rpx;
color: #EB554D;
font-weight: 500;
line-height: 74rpx;
margin: 8rpx 0;
}
.fz20{
font-size: 24rpx;
}
.old-price{
font-size: 24rpx;
color: #B9B9B9;
}
.old-price .row-line{
text-decoration: line-through;
}
.info-r-box{
font-size: 24rpx;
color: #B9B9B9;
}
.share-btn{
width: 102rpx !important;
height: 48rpx !important;
padding: 0;
margin: 0 !important;
background: #EB554D;
border-radius: 28rpx 0px 0px 28rpx;
font-size: 22rpx;
color: #fff;
margin-top: 20rpx !important;
margin-left: 28rpx !important;
}
.share-btn image{
width: 23rpx;
height: 27rpx;
margin-right: 6rpx;
}
.title-box{
margin: 40rpx auto 44rpx;
}
.title-box .row-line{
width: 58rpx;
height: 2rpx;
background: #000;
}
.title-box .title{
font-size: 28rpx;
color: #000;
margin: 0 18rpx;
font-weight: 500;
}
.produce-detail{
width: 100%;
}
.produce-detail image{
width: 100%;
}
.footer-box{
width: 100%;
height: 160rpx;
background: #fff;
position: fixed;
bottom: 0;
left: 0;
padding: 38rpx 40rpx 38rpx 92rpx;
}
.home{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #202020;
margin-right: 76rpx;
}
.home image{
width: 48rpx;
height: 48rpx;
}
.submit-btn{
margin: 0;
}

70
pages/goodsList/index.js

@ -0,0 +1,70 @@
// pages/goodsList/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
toDetail(e){
wx.navigateTo({
url: '/pages/goodsDetail/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

4
pages/goodsList/index.json

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "商品列表"
}

16
pages/goodsList/index.wxml

@ -0,0 +1,16 @@
<!--pages/goodsList/index.wxml-->
<view class="goodsList-page">
<view class="goods-list">
<view class="goods-item acea-row" wx:for="{{3}}" :key="index" bindtap="toDetail" data-id="id">
<image src="../../images/jixiang.png" mode="aspectFill"></image>
<view class="goods-info">
<view class="name line2">瑞梦思·夏季新款独家定制款独家定制智能款独家定制智能智能床垫</view>
<view class="desc">高级智能床垫·安心休息</view>
<view class="price">
<text class="s-word">¥</text>
<text>129000</text>
</view>
</view>
</view>
</view>
</view>

48
pages/goodsList/index.wxss

@ -0,0 +1,48 @@
/* pages/goodsList/index.wxss */
.goodsList-page{
width: 100%;
min-height: 100vh;
background: #F7F7F7;
}
.goods-list{
width: 100%;
padding: 40rpx;
}
.goods-item{
width: 100%;
height: 226rpx;
background: #fff;
border-radius: 12rpx;
padding: 24rpx 32rpx;
margin-bottom: 20rpx;
}
.goods-item image{
width: 178rpx;
height: 178rpx;
border-radius: 8rpx;
margin-right: 32rpx;
}
.goods-info{
width: calc(100% - 210rpx);
display: flex;
flex-direction: column;
justify-content: space-between;
}
.name{
color: #202020;
font-size: 28rpx;
line-height: 40rpx;
font-weight: 500;
}
.desc{
font-size: 22rpx;
color: #a4a4a4;
}
.price{
font-size: 36rpx;
color: #EB554D;
font-weight: 500;
}
.price .s-word{
font-size: 24rpx;
}

89
pages/home/index.js

@ -0,0 +1,89 @@
// pages/home/index.js
Page({
/**
* 页面的初始数据
*/
data: {
authorize: false,
canIUseGetUserProfile: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
getUserInfoProfile(){
wx.getUserProfile({
lang: 'zh_CN',
desc: '需要获取您的信息用来展示',
success: res => {
console.log(res)
uni.showLoading({
title: '登录中',
})
},
})
},
toDetial(){
wx.navigateTo({
url: '/pages/goodsDetail/index',
})
},
toCompany(){
wx.navigateTo({
url: '/pages/companyInfo/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

4
pages/home/index.json

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationStyle": "custom"
}

51
pages/home/index.wxml

@ -0,0 +1,51 @@
<!--pages/home/index.wxml-->
<view class="home-page">
<view class="top-box">
<image src="../../images/index-top.png"></image>
</view>
<view class="company-info-box acea-row-nowrap" bindtap="toCompany">
<image src="../../images/company-bg.png" class="info-bg"></image>
<view class="info-box acea-row-nowrap row-between">
<image src="../../images/logo.png"></image>
<view class="introduce-box acea-row row-column-between">
<view class="name">深圳市瑞梦思时代科技有限公司</view>
<view class="desc">瑞蓢国际集团旗下全资子公司,以能量家居系统、智慧健康睡眠生态系统为主打的核心品牌。</view>
</view>
</view>
</view>
<view class="goods-list-box">
<view class="title-box acea-row row-center row-middle">
<view class="row-line"></view>
<view class="title">商品介绍</view>
<view class="row-line"></view>
</view>
<view class="goods-item" bindtap="toDetial">
<image src="../../images/jixiang.png" mode="widthFix"></image>
</view>
<view class="goods-item">
<image src="../../images/chongsu.png" mode="widthFix"></image>
</view>
</view>
<view class="form-box">
<view class="tips-box acea-row row-middle">
<image src="../../images/tip-icon.png"></image>
<text>输入姓名电话立即咨询!</text>
</view>
<view class="form">
<image src="../../images/company-bg.png" class="info-bg"></image>
<view class="inp-box">
<view class="inp-item acea-row row-middle">
<text class="label">您的姓名:</text>
<input type="text" placeholder="请输入您的姓名" />
</view>
<view class="inp-item acea-row row-middle">
<text class="label">您的电话:</text>
<input type="text" placeholder="请输入您的电话" />
</view>
</view>
</view>
<button class="submit-btn" wx:if="canIUseGetUserProfile" bindtap="getUserInfoProfile">立即咨询</button>
<button class="submit-btn" wx:else open-type="getUserInfo" bindtap="getUserInfo">立即咨询</button>
<view class="submit-btn">立即咨询</view>
</view>
</view>

124
pages/home/index.wxss

@ -0,0 +1,124 @@
/* pages/home/index.wxss */
.top-box{
width: 100%;
height: 874rpx;
}
.top-box image{
width: 100%;
height: 100%;
}
.company-info-box{
width: 670rpx;
height: 268rpx;
position: relative;
margin: -124rpx auto 0;
}
.company-info-box .info-bg{
width: 100%;
height: 100%;
position: absolute;
}
.info-box{
width: 100%;
position: absolute;
top: 0;
z-index: 2;
padding: 44rpx 20rpx 42rpx 40rpx;
}
.info-box image{
width: 150rpx;
height: 182rpx;
}
.introduce-box{
width: 440rpx;
}
.introduce-box .name{
font-size: 30rpx;
color: #514E4E;
font-weight: 600;
}
.introduce-box .desc{
font-size: 24rpx;
color: #8A8A8A;
}
.goods-list-box{
width: 100%;
margin-top: 48rpx;
}
.title-box{
margin-bottom: 30rpx;
}
.row-line{
width: 108rpx;
height: 2rpx;
background: #959595;
}
.title-box .title{
font-size: 32rpx;
color: #959595;
margin: 0 18rpx;
font-weight: 500;
}
.goods-item{
width: 100%;
margin-bottom: 16rpx;
}
.goods-item image{
width: 100%;
}
.form-box{
width: 100%;
padding: 80rpx 40rpx;
position: relative;
}
.tips-box{
font-size: 24rpx;
color: #1D1D1D;
margin-bottom: 32rpx;
}
.tips-box image{
width: 24.5rpx;
height: 24.5rpx;
margin: 2rpx 4rpx 0 0 ;
}
.form{
width: 100%;
height: 232rpx;
font-size: 24rpx;
color: #1D1D1D;
position: relative;
}
.form .info-bg{
width: 100%;
height: 232rpx;
position: absolute;
}
.inp-box{
width: 100%;
position: absolute;
z-index: 3;
padding: 48rpx 130rpx;
}
.inp-item{
width: 100%;
height: 50rpx;
border: 2rpx solid #1D1D1D;
border-radius: 8rpx;
padding: 0rpx 30rpx;
margin-bottom: 40rpx;
}
.inp-item input{
width: 60%;
}
.label{
margin-right: 4rpx;
}
.submit-btn{
width: 318rpx !important;
padding: 0 !important;
}

50
pages/index/index.js

@ -0,0 +1,50 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
// canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName' // 如需尝试获取用户信息可改为false
canIUseOpenData: false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
console.log(wx.getUserProfile)
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

3
pages/index/index.json

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

23
pages/index/index.wxml

@ -0,0 +1,23 @@
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseOpenData}}">
<view class="userinfo-avatar" bindtap="bindViewTap">
<open-data type="userAvatarUrl"></open-data>
</view>
<open-data type="userNickName"></open-data>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<view wx:else> 请使用1.4.4及以上版本基础库 </view>
</block>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>

19
pages/index/index.wxss

@ -0,0 +1,19 @@
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}

167
pages/login/index.js

@ -0,0 +1,167 @@
// pages/login/index.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
login: false,
canIUseGetUserProfilefalse: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let userInfo = wx.getStorageSync('userInfo')
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
this.setData({
code: res.code
})
}
})
},
setUserInfo(){
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (response) => {
wx.showLoading({
title: '登陆中...',
})
let data = {
code: this.data.code,
iv: response.iv,
encryptedData:response.encryptedData,
spread: 0,
login_type: 0
}
app.http('POST','wxapp/auth',data).then(
result =>{
if(result.data.success){
wx.hideLoading()
wx.setStorageSync('token', 'Bearer '+ result.data.data.token)
wx.setStorageSync('userInfo', result.data.data.user)
wx.showToast({
title: '授权成功!',
duration: 1500
})
if(!result.data.data.user.phone){
this.setData({
login: true
})
} else{
setTimeout(()=>{
wx.navigateBack({
delta: 1,
})
},1500)
}
} else{
wx.showToast({
title: result.data.msg,
icon : 'none'
})
}
}
)
}
})
},
getPhoneNumber(e) {
if(e.detail.errMsg == 'getPhoneNumber:ok'){
app.http('post','wxapp/binding',
{encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}).then((res)=>{
if(res.data.success){
app.getInfo();
wx.showToast({
title: res.data.msg,
duration: 1500
})
setTimeout(()=>{
wx.navigateBack({
delta: 1,
})
},1500)
} else{
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
})
setTimeout(()=>{
wx.navigateBack({
delta: 1,
})
},2000)
}
})
}
},
back(){
wx.navigateBack({
delta: 1,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

4
pages/login/index.json

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "授权登录"
}

17
pages/login/index.wxml

@ -0,0 +1,17 @@
<!--pages/login/index.wxml-->
<view class="authorization">
<open-data class="user-avatar" type="userAvatarUrl"></open-data>
<open-data class="user-name" type="userNickName"></open-data>
<view class="login-notice">为了提供更优质的服务,需要您授权基本信息</view>
<button class="wx-btn" bindtap='getUserProfile' wx:if="{{!login && canIUseGetUserProfile}}">
<text>微信授权登录</text>
</button>
<button open-type="getPhoneNumber" class="wx-btn" bindgetphonenumber="getPhoneNumber" wx:if="{{login}}">
<text>绑定手机号</text>
</button>
<view class="login-notice" wx:if="{{!login && !canIUseGetUserProfile}}">请升级微信版本后再授权</view>
<button class="wx-btn btn" bindtap="back">
<text>暂不授权</text>
</button>
</view>

46
pages/login/index.wxss

@ -0,0 +1,46 @@
/* pages/login/index.wxss */
.authorization {
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
padding-top: 190rpx;
}
.user-avatar {
width: 192rpx;
height: 192rpx;
border-radius: 50%;
overflow: hidden;
}
.user-name{
margin: 40rpx 0;
}
.login-notice{
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
color: #000;
padding-bottom: 90rpx;
}
.authorization .wx-btn {
width: 640rpx !important;
height: 86rpx!important;
background: linear-gradient(274deg, #EE7F7B 0%, #EB5750 100%);
border-radius: 60rpx!important;
text-align: center!important;
line-height: 86rpx!important;
margin-bottom: 36rpx!important;
display: flex!important;
align-items: center!important;
justify-content: center!important;
color: #fff;
font-weight: 500 !important;
}
.authorization .btn{
background: #fff !important;
border: 4rpx solid #EE7F7B;
color: #EE7F7B !important;
}

74
project.config.json

@ -0,0 +1,74 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": [
{
"type": "file",
"value": ".eslintrc.js"
}
]
},
"setting": {
"bundle": false,
"userConfirmedBundleSwitch": false,
"urlCheck": true,
"scopeDataCheck": false,
"coverView": true,
"es6": true,
"postcss": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"minified": true,
"autoAudits": false,
"newFeature": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"useIsolateContext": true,
"nodeModules": false,
"enhance": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"enableEngineNative": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"showES6CompileOption": false,
"minifyWXML": true
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wxdb1f3c2997df014a",
"projectname": "%E7%91%9E%E6%A2%A6%E6%80%9D%E5%B0%8F%E7%A8%8B%E5%BA%8F",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}

7
sitemap.json

@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

19
utils/util.js

@ -0,0 +1,19 @@
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
module.exports = {
formatTime
}
Loading…
Cancel
Save