commit b043c0b6715adb4e98ff0ea01514c4ef0d6484d5 Author: 杨豪 <781521347@qq.com> Date: Thu Nov 25 16:22:01 2021 +0800 瑞梦思 diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/.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: {}, +} diff --git a/app.js b/app.js new file mode 100644 index 0000000..5a55b4c --- /dev/null +++ b/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/', + } +}) diff --git a/app.json b/app.json new file mode 100644 index 0000000..49d61fc --- /dev/null +++ b/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" +} diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..f5deb0e --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/images/chongsu.png b/images/chongsu.png new file mode 100644 index 0000000..258536c Binary files /dev/null and b/images/chongsu.png differ diff --git a/images/company-bg.png b/images/company-bg.png new file mode 100644 index 0000000..96e350c Binary files /dev/null and b/images/company-bg.png differ diff --git a/images/company-info.png b/images/company-info.png new file mode 100644 index 0000000..1816953 Binary files /dev/null and b/images/company-info.png differ diff --git a/images/home.png b/images/home.png new file mode 100644 index 0000000..050f3d0 Binary files /dev/null and b/images/home.png differ diff --git a/images/index-top.png b/images/index-top.png new file mode 100644 index 0000000..e85662f Binary files /dev/null and b/images/index-top.png differ diff --git a/images/jixiang.png b/images/jixiang.png new file mode 100644 index 0000000..662f219 Binary files /dev/null and b/images/jixiang.png differ diff --git a/images/list.png b/images/list.png new file mode 100644 index 0000000..6003839 Binary files /dev/null and b/images/list.png differ diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..aa4b114 Binary files /dev/null and b/images/logo.png differ diff --git a/images/share.png b/images/share.png new file mode 100644 index 0000000..8cebaa8 Binary files /dev/null and b/images/share.png differ diff --git a/images/tip-icon.png b/images/tip-icon.png new file mode 100644 index 0000000..174d0b7 Binary files /dev/null and b/images/tip-icon.png differ diff --git a/images/title1.png b/images/title1.png new file mode 100644 index 0000000..85128c7 Binary files /dev/null and b/images/title1.png differ diff --git a/images/title2.png b/images/title2.png new file mode 100644 index 0000000..11fd4a3 Binary files /dev/null and b/images/title2.png differ diff --git a/pages/companyInfo/index.js b/pages/companyInfo/index.js new file mode 100644 index 0000000..e4ab356 --- /dev/null +++ b/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 () { + + } +}) \ No newline at end of file diff --git a/pages/companyInfo/index.json b/pages/companyInfo/index.json new file mode 100644 index 0000000..e4d5978 --- /dev/null +++ b/pages/companyInfo/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "公司信息" +} \ No newline at end of file diff --git a/pages/companyInfo/index.wxml b/pages/companyInfo/index.wxml new file mode 100644 index 0000000..3917c3a --- /dev/null +++ b/pages/companyInfo/index.wxml @@ -0,0 +1,22 @@ + + + + + + + + + 深圳市瑞梦思时代科技有限公司,瑞蓢国际集团旗下全资子公司,以能量家居系统、智慧健康睡眠生态系统为主打的核心品牌。当前旗下产品包括“重塑本元”、“吉祥卧”床垫,“少年强”青少年床垫,旅行垫,魔术减负能量背包等。\n + 瑞梦思以“专注每一天,健康每一夜”为目标,为人们研发贯穿生活各方面的能量家居产品,让每个家庭,每个人都能从源头开始防患于未然,远离亚健康,享受真正健康轻松的幸福生活。 + + + + + + + + + + + 更多商品 + diff --git a/pages/companyInfo/index.wxss b/pages/companyInfo/index.wxss new file mode 100644 index 0000000..75f525e --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/goodsDetail/index.js b/pages/goodsDetail/index.js new file mode 100644 index 0000000..650f442 --- /dev/null +++ b/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 () { + + } +}) \ No newline at end of file diff --git a/pages/goodsDetail/index.json b/pages/goodsDetail/index.json new file mode 100644 index 0000000..ae4a221 --- /dev/null +++ b/pages/goodsDetail/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "商品详情" +} \ No newline at end of file diff --git a/pages/goodsDetail/index.wxml b/pages/goodsDetail/index.wxml new file mode 100644 index 0000000..9d6fbe1 --- /dev/null +++ b/pages/goodsDetail/index.wxml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + 瑞梦思·布胡斯智能床垫 + 129000-289000 + 原价:¥99999 + + + 销量:999+ + + + + + + 产商品情 + + + + + + + + + + + + + 首页 + + + + 商品列表 + + + 立即咨询 + + + + + diff --git a/pages/goodsDetail/index.wxss b/pages/goodsDetail/index.wxss new file mode 100644 index 0000000..a9ced31 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/goodsList/index.js b/pages/goodsList/index.js new file mode 100644 index 0000000..620dff3 --- /dev/null +++ b/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 () { + + } +}) \ No newline at end of file diff --git a/pages/goodsList/index.json b/pages/goodsList/index.json new file mode 100644 index 0000000..c98de42 --- /dev/null +++ b/pages/goodsList/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "商品列表" +} \ No newline at end of file diff --git a/pages/goodsList/index.wxml b/pages/goodsList/index.wxml new file mode 100644 index 0000000..378eaa3 --- /dev/null +++ b/pages/goodsList/index.wxml @@ -0,0 +1,16 @@ + + + + + + + 瑞梦思·夏季新款独家定制款独家定制智能款独家定制智能智能床垫 + 高级智能床垫·安心休息 + + + 129000 + + + + + diff --git a/pages/goodsList/index.wxss b/pages/goodsList/index.wxss new file mode 100644 index 0000000..aa7ccb8 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/home/index.js b/pages/home/index.js new file mode 100644 index 0000000..bdfd9a3 --- /dev/null +++ b/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 () { + + } +}) \ No newline at end of file diff --git a/pages/home/index.json b/pages/home/index.json new file mode 100644 index 0000000..965b8e8 --- /dev/null +++ b/pages/home/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationStyle": "custom" +} \ No newline at end of file diff --git a/pages/home/index.wxml b/pages/home/index.wxml new file mode 100644 index 0000000..acbe672 --- /dev/null +++ b/pages/home/index.wxml @@ -0,0 +1,51 @@ + + + + + + + + + + + 深圳市瑞梦思时代科技有限公司 + 瑞蓢国际集团旗下全资子公司,以能量家居系统、智慧健康睡眠生态系统为主打的核心品牌。 + + + + + + + 商品介绍 + + + + + + + + + + + + + 输入姓名电话立即咨询! + + + + + + 您的姓名: + + + + 您的电话: + + + + + + + 立即咨询 + + diff --git a/pages/home/index.wxss b/pages/home/index.wxss new file mode 100644 index 0000000..f14c7e2 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js new file mode 100644 index 0000000..543a3f9 --- /dev/null +++ b/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 + }) + } +}) diff --git a/pages/index/index.json b/pages/index/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml new file mode 100644 index 0000000..f00d294 --- /dev/null +++ b/pages/index/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + 请使用1.4.4及以上版本基础库 + + + + {{userInfo.nickName}} + + + + {{motto}} + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss new file mode 100644 index 0000000..eb64203 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/login/index.js b/pages/login/index.js new file mode 100644 index 0000000..4ff5d7a --- /dev/null +++ b/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 () { + + } +}) \ No newline at end of file diff --git a/pages/login/index.json b/pages/login/index.json new file mode 100644 index 0000000..986c90e --- /dev/null +++ b/pages/login/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "授权登录" +} \ No newline at end of file diff --git a/pages/login/index.wxml b/pages/login/index.wxml new file mode 100644 index 0000000..38fe82a --- /dev/null +++ b/pages/login/index.wxml @@ -0,0 +1,17 @@ + + + + + 为了提供更优质的服务,需要您授权基本信息 + + + 请升级微信版本后再授权 + + + diff --git a/pages/login/index.wxss b/pages/login/index.wxss new file mode 100644 index 0000000..ef2d291 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..56c5d74 --- /dev/null +++ b/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": [] + } + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/utils/util.js b/utils/util.js new file mode 100644 index 0000000..764bc2c --- /dev/null +++ b/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 +}