diff --git a/api/interfaces/enroll.js b/api/interfaces/enroll.js
index 0805d56..a41a7c6 100644
--- a/api/interfaces/enroll.js
+++ b/api/interfaces/enroll.js
@@ -2,7 +2,7 @@
import {req} from "../request"
//微信授权登录
-const record = (code, iv, encryptedData) => req({url: "auth/openwx", method: "POST", data: {code: code, iv: iv, encryptedData: encryptedData}})
+const record = (code, iv, encryptedData, parent_id) => req({url: "auth/openwx", method: "POST", data: {code: code, iv: iv, encryptedData: encryptedData, parent_id: parent_id || 0}})
//微信手机授权
const bindmobile = (code, iv, mobile) => req({url: "auth/bindmobile", method: "POST", data: {code: code, iv: iv, mobile: mobile}})
diff --git a/api/interfaces/user.js b/api/interfaces/user.js
index 267b642..0483c88 100644
--- a/api/interfaces/user.js
+++ b/api/interfaces/user.js
@@ -58,6 +58,9 @@ const washcarBuy = (welfare_id, right_id, qty, address_id, is_deliver) => req({u
// 收银台提交
const washcarCreate = (welfare_id, right_id, qty, address_id, is_deliver) => req({url: "washcar/create", method: "POST", data:{welfare_id : welfare_id, right_id : right_id, qty : qty, address_id : address_id || '', is_deliver : is_deliver}})
+// 我的分享
+const myshare = (parent_id) => req({url: "user/share",data:{parent_id : parent_id || ''}})
+
export default({
index,
mobiles,
@@ -77,5 +80,6 @@ export default({
unicom,
merchant_card,
washcarBuy,
- washcarCreate
+ washcarCreate,
+ myshare
})
diff --git a/app.json b/app.json
index a0a1713..8ec5ea7 100644
--- a/app.json
+++ b/app.json
@@ -28,7 +28,8 @@
"pages/classify/classify",
"pages/washcar/washcar",
"pages/makeForm/makeForm",
- "pages/car/index"
+ "pages/car/index",
+ "pages/code/code"
],
"window": {
"backgroundTextStyle": "light",
diff --git a/pages/chooseTel/chooseTel.js b/pages/chooseTel/chooseTel.js
index 05fd9f6..536b210 100644
--- a/pages/chooseTel/chooseTel.js
+++ b/pages/chooseTel/chooseTel.js
@@ -126,9 +126,8 @@ Page({
*/
loginGo(e) {
let username = e.currentTarget.dataset.name
- const wechatUserId = wx.getStorageSync("wechatUser")
- wx.$api.enroll.tel(wechatUserId, username).then(res=>{
+ wx.$api.enroll.tel(this.data.wechatUserId, username).then(res=>{
app.globalData.token = res.data.token
app.globalData.isUser = true
diff --git a/pages/code/code.js b/pages/code/code.js
new file mode 100644
index 0000000..4bbaac3
--- /dev/null
+++ b/pages/code/code.js
@@ -0,0 +1,170 @@
+/*
+ * 本时生活
+ */
+
+ Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ qrcode : '', //二维码
+ userInfo: '', //我的信息
+ isImgLay: false, //是否显示图片弹出层
+ parentId: '' //是否分享进入
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad (options) {
+ // 判断是否由分享进入
+ if(options.type == "share"){
+ // 写入缓存
+ this.setData({
+ parentId: options.parent_id
+ })
+ }
+ wx.$api.user.myshare(this.data.parentId).then(res=>{
+ this.setData({
+ qrcode : res.data.qrcode,
+ userInfo : res.data.user
+ })
+ })
+ },
+
+ /**
+ * 绘图
+ */
+ dowImg(){
+ wx.showLoading({
+ title: '加载中',
+ })
+
+ let avatarImg = new Promise(success=>{
+ wx.getImageInfo({
+ src : this.data.userInfo.avatar,
+ success : res => {
+ success(res.path)
+ }
+ })
+ })
+
+ // 下载素材
+ let codeImg = new Promise(success => {
+ wx.getImageInfo({
+ src : this.data.qrcode,
+ success : res => {
+ success(res.path)
+ }
+ })
+ })
+
+ Promise.all([codeImg, avatarImg]).then(res => {
+ // 绘制海报
+ const ctx = wx.createCanvasContext('qrcodeCard')
+ ctx.save()
+
+ // 绘制背景
+ ctx.setFillStyle('#f7662d')
+ ctx.fillRect(0, 0, 375, 603)
+
+ // 绘制背景
+ ctx.drawImage('/static/img/user-codeImg-down.png', 0, 0, 375, 650)
+
+ // 绘制二维码
+ ctx.drawImage(res[0], 114, 390, 150, 150)
+
+ // 文字
+ ctx.setFontSize(16)
+ ctx.setFillStyle("#2f3245")
+ ctx.setTextAlign('center')
+ ctx.fillText(this.data.userInfo.nickname, 194, 350 , 270)
+
+ // 文字
+ ctx.setFontSize(14)
+ ctx.setFillStyle("#af7700")
+ ctx.setTextAlign('center')
+ ctx.fillText(this.data.userInfo.nickname + " -- " + "邀请您进入本时生活", 188, 570 , 270)
+
+ ctx.save();
+ ctx.beginPath(); //开始绘制
+ ctx.arc(70 / 2 + 156, 70 / 2 + 250, 70 / 2, 0, Math.PI * 2, false);
+ ctx.clip();
+ ctx.drawImage(res[1], 156, 250, 70, 70);
+
+ // 保存图片
+ ctx.draw(true, () => {
+ wx.hideLoading()
+ wx.canvasToTempFilePath({
+ canvasId: 'qrcodeCard',
+ x: 0,
+ y: 0,
+ success: res => {
+ wx.saveImageToPhotosAlbum({
+ filePath: res.tempFilePath,
+ success : res=>{
+ wx.showToast({
+ title: '分享海报已保存至相册',
+ icon : 'none'
+ })
+ },
+ fail : err=>{
+ wx.showModal({
+ title : '提示',
+ content : '暂未授权小程序写入您的相册,无法存储二维码海报',
+ confirmColor: '#d82526',
+ confirmText : '去设置',
+ success : info=>{
+ if (info.confirm){
+ wx.openSetting()
+ }
+ }
+ })
+ },
+ complete: e => {
+ console.log(e)
+ }
+ })
+ }
+ })
+ })
+
+ }).catch(err=>{
+ wx.showToast({
+ title: '海报下载,请检查网络',
+ icon : 'none'
+ })
+ })
+ },
+
+ /**
+ * 图片弹出层
+ */
+ removeSaveImg(){
+ this.setData({
+ isImgLay: !this.data.isImgLay
+ })
+ },
+
+ /**
+ * 保存图片到本地
+ */
+ saveImg(){
+ this.dowImg();
+ this.setData({
+ isImgLay: !this.data.isImgLay
+ })
+ },
+
+ /**
+ * 分享
+ */
+ onShareAppMessage(){
+ return {
+ title : this.data.userInfo.nickname + "邀请您进入本时生活",
+ imageUrl: "",
+ query : "/pages/code/code?parent_id=" + this.data.userInfo.user_id + "&type=share"
+ }
+ }
+})
\ No newline at end of file
diff --git a/pages/code/code.json b/pages/code/code.json
new file mode 100644
index 0000000..41c15a0
--- /dev/null
+++ b/pages/code/code.json
@@ -0,0 +1,6 @@
+{
+ "usingComponents": {},
+ "navigationBarTitleText": "我的邀请码",
+ "navigationBarBackgroundColor": "#332829",
+ "navigationBarTextStyle": "white"
+}
\ No newline at end of file
diff --git a/pages/code/code.wxml b/pages/code/code.wxml
new file mode 100644
index 0000000..791e45f
--- /dev/null
+++ b/pages/code/code.wxml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+ {{userInfo.nickname}}
+
+
+
+
+
+
+
+
+ 下载海报
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{userInfo.nickname}}
+
+
+
+
+
+ 邀请好友扫码,即可绑定关系
+
+
+
+
+
+
+
diff --git a/pages/code/code.wxss b/pages/code/code.wxss
new file mode 100644
index 0000000..fcd91bb
--- /dev/null
+++ b/pages/code/code.wxss
@@ -0,0 +1,207 @@
+page {
+ background-color: #f5ecd8;
+}
+
+/* 标题 */
+.codeTitle {
+ width: 100vw;
+ height: 45vh;
+ text-align: center;
+ position: absolute;
+ left: 0;
+ top: 0;
+}
+
+/* 按钮 */
+.codeShare {
+ width: 100%;
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ background-color: #333333;
+ display: flex;
+ padding: 30rpx 20rpx 40rpx;
+ box-sizing: border-box;
+ z-index: 9;
+}
+
+.codeShare-label {
+ width: calc(50% - 20rpx) !important;
+ margin: 0 10rpx;
+ font-weight: normal;
+ text-align: center;
+ height: 80rpx;
+ line-height: 80rpx;
+ padding: 0;
+ border-radius: 60rpx;
+ border: #c1a468 2rpx solid;
+ font-size: 32rpx;
+ color: #412f0b;
+ background: linear-gradient(to bottom, #eee3c8, #c1a468);
+}
+
+.codeShare-button {
+ color: #ffd887;
+ background: transparent;
+}
+
+/* 二维码 */
+.codeCont {
+ position: relative;
+ width: 80vw;
+ left: 10vw;
+ top: 31.5vh;
+ background-color: #fff;
+ box-sizing: border-box;
+ border-radius: 10rpx;
+ justify-items: center;
+ text-align: center;
+ z-index: 8;
+ margin-bottom: 200rpx;
+}
+
+.codeCont-code {
+ width: 340rpx;
+ height: 340rpx;
+ margin: 20rpx 0 40rpx;
+}
+
+.codeCont-tips {
+ border-radius: 10rpx 10rpx 0 0;
+ width: 100%;
+}
+
+.codeCont-gold {
+ position: absolute;
+ width: 100rpx;
+ height: 100rpx;
+ right: 40rpx;
+ top: -40rpx;
+}
+
+.codeCont-text {
+ position: absolute;
+ width: 100%;
+ text-align: center;
+ top: 30rpx;
+ left: 0;
+ color: #71552d;
+ font-weight: 600;
+}
+
+.codeCont-avatar {
+ width: 130rpx;
+ height: 130rpx;
+ border-radius: 50%;
+ margin-bottom: 5rpx;
+ border: 6rpx solid #ebdcb9;
+}
+
+.codeCont-words {
+ margin-top: 40rpx;
+ width: 100%;
+}
+
+/* 弹窗背景图 */
+.user-lay{
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-box-pack: center;
+ position: fixed;
+ background: rgba(0, 0, 0, .6);
+ height: 100vh;
+ width: 100vw;
+ top: 0;
+ left: 0;
+ z-index: 99;
+ box-sizing: border-box;
+}
+
+/* canvas */
+.canvasImg{
+ position: absolute;
+ left: -1000%;
+ height: 650px;
+ width: 375px;
+ background: #fbf6f0;
+}
+
+/* 图片弹出层 */
+.sign-img-lay{
+ text-align: center;
+}
+
+.sign-img-src{
+ width: 70vw;
+ vertical-align: top;
+}
+
+.sign-img-btn[size="mini"]{
+ margin-top: 40rpx;
+ background: #f5d48f;
+ font-weight: normal;
+ color: #2f3245;
+ height: 90rpx;
+ line-height: 90rpx;
+ padding: 0;
+ width: 70vw;
+}
+
+.remove-btn[size="mini"]{
+ margin-top: 20rpx;
+ background: #101010;
+ color: #e5c175;
+ font-weight: normal;
+}
+
+/* 背景 */
+.user-back {
+ position: relative;
+ width: 100%;
+ height:600rpx;
+ text-align: center;
+ margin-top: 100rpx;
+}
+
+.user-back-img {
+ position: absolute;
+ width: 70vw;
+ left: 15vw;
+ top: 0;
+ height: 100%;
+ margin: 0 auto;
+ border-radius: 10rpx;
+}
+
+.user-back-cont {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ color: #2f3245;
+}
+
+.user-back-avatar image {
+ width: 140rpx;
+ height: 140rpx;
+ border-radius: 50%;
+ margin-top: -60rpx;
+ margin-bottom: 20rpx;
+ border: 6rpx solid #fff1d1;
+}
+
+.user-back-yard {
+ margin-top: 40rpx;
+}
+
+.codeBack-yard-name {
+ font-size: 28rpx;
+ color: #af7700;
+}
+
+.user-back-yard image {
+ width: 240rpx;
+ height: 240rpx;
+ margin-bottom: 20rpx;
+}
\ No newline at end of file
diff --git a/pages/index/index.js b/pages/index/index.js
index 13f6e8f..d012a21 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -35,6 +35,20 @@ Page({
}
},
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+ // 判断是否由分享进入
+ if(options.parent_id !== ""){
+ // 写入缓存
+ wx.setStorage({
+ key : 'parentId',
+ data : options.parent_id
+ })
+ }
+ },
+
/**
* 生命周期函数--监听页面显示
*/
diff --git a/pages/login/login.js b/pages/login/login.js
index 83f4b9f..6cd0ee3 100644
--- a/pages/login/login.js
+++ b/pages/login/login.js
@@ -78,7 +78,7 @@ Page({
},
fail : res => {
//拒绝授权
- this.showErrorModal('您拒绝了请求');
+ // this.showErrorModal('您拒绝了请求');
return;
}
})
@@ -92,7 +92,10 @@ Page({
iv = this.data.iv,
encryptedData = this.data.encryptedData
- wx.$api.enroll.record(code, iv, encryptedData).then(res=>{
+ // 检查用户扫码进入
+ const parentId = wx.getStorageSync("parentId")
+
+ wx.$api.enroll.record(code, iv, encryptedData, parentId).then(res=>{
getApp().globalData.token = res.data.token
// 更新全局存储器用户状态
@@ -127,6 +130,9 @@ Page({
key : 'users',
data : res.data.users
})
+
+ // 清除扫码进入获取parent_id的缓存
+ wx.removeStorageSync('parentId')
})
}
diff --git a/pages/user/user.wxml b/pages/user/user.wxml
index 4a3192e..48df59b 100644
--- a/pages/user/user.wxml
+++ b/pages/user/user.wxml
@@ -169,3 +169,16 @@
-->
+
+
+
+ 我的工具
+
+
+
+
+
+ 我的邀请码
+
+
+
\ No newline at end of file
diff --git a/project.private.config.json b/project.private.config.json
index 171800e..95696f2 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -120,6 +120,12 @@
"pathName": "pages/car/index",
"query": "",
"scene": null
+ },
+ {
+ "name": "pages/code/code",
+ "pathName": "pages/code/code",
+ "query": "",
+ "scene": null
}
]
}
diff --git a/static/img/Account_icon.png b/static/img/Account_icon.png
index 0276e73..a639f74 100644
Binary files a/static/img/Account_icon.png and b/static/img/Account_icon.png differ
diff --git a/static/img/Account_icon_tips.png b/static/img/Account_icon_tips.png
index 96bb03b..72d15e1 100644
Binary files a/static/img/Account_icon_tips.png and b/static/img/Account_icon_tips.png differ
diff --git a/static/img/activity_coupon.png b/static/img/activity_coupon.png
index 415fa79..b90a681 100644
Binary files a/static/img/activity_coupon.png and b/static/img/activity_coupon.png differ
diff --git a/static/img/class_back_01.png b/static/img/class_back_01.png
index c2b492b..683823d 100644
Binary files a/static/img/class_back_01.png and b/static/img/class_back_01.png differ
diff --git a/static/img/coupon_icon_00.png b/static/img/coupon_icon_00.png
index 0b9e8a6..4b69dbe 100644
Binary files a/static/img/coupon_icon_00.png and b/static/img/coupon_icon_00.png differ
diff --git a/static/img/coupon_icon_01.png b/static/img/coupon_icon_01.png
index ac023d8..9879416 100644
Binary files a/static/img/coupon_icon_01.png and b/static/img/coupon_icon_01.png differ
diff --git a/static/img/makeForm_checked.png b/static/img/makeForm_checked.png
index d242730..856f806 100644
Binary files a/static/img/makeForm_checked.png and b/static/img/makeForm_checked.png differ
diff --git a/static/img/makeForm_title_00.png b/static/img/makeForm_title_00.png
index 7316655..4a53084 100644
Binary files a/static/img/makeForm_title_00.png and b/static/img/makeForm_title_00.png differ
diff --git a/static/img/makeForm_title_01.png b/static/img/makeForm_title_01.png
index 6afb8c7..a923f03 100644
Binary files a/static/img/makeForm_title_01.png and b/static/img/makeForm_title_01.png differ
diff --git a/static/img/makeForm_title_02.png b/static/img/makeForm_title_02.png
index 648b540..d732f6a 100644
Binary files a/static/img/makeForm_title_02.png and b/static/img/makeForm_title_02.png differ
diff --git a/static/img/null_icon.png b/static/img/null_icon.png
index de104c3..ca299cb 100644
Binary files a/static/img/null_icon.png and b/static/img/null_icon.png differ
diff --git a/static/img/staff_null.png b/static/img/staff_null.png
index 350081b..2f98c33 100644
Binary files a/static/img/staff_null.png and b/static/img/staff_null.png differ
diff --git a/static/img/subscribe.png b/static/img/subscribe.png
index 5b15da5..dc66abb 100644
Binary files a/static/img/subscribe.png and b/static/img/subscribe.png differ
diff --git a/static/img/user-codeGold.png b/static/img/user-codeGold.png
new file mode 100644
index 0000000..b848ac1
Binary files /dev/null and b/static/img/user-codeGold.png differ
diff --git a/static/img/user-codeImg-active.png b/static/img/user-codeImg-active.png
new file mode 100644
index 0000000..2dbb15e
Binary files /dev/null and b/static/img/user-codeImg-active.png differ
diff --git a/static/img/user-codeImg-down.png b/static/img/user-codeImg-down.png
new file mode 100644
index 0000000..58ff1cd
Binary files /dev/null and b/static/img/user-codeImg-down.png differ
diff --git a/static/img/user-codeTips-01.png b/static/img/user-codeTips-01.png
new file mode 100644
index 0000000..f8830a9
Binary files /dev/null and b/static/img/user-codeTips-01.png differ
diff --git a/static/img/user-codeTips-02.png b/static/img/user-codeTips-02.png
new file mode 100644
index 0000000..d9f9d61
Binary files /dev/null and b/static/img/user-codeTips-02.png differ
diff --git a/static/img/user-codeTitle.png b/static/img/user-codeTitle.png
new file mode 100644
index 0000000..4a33bfb
Binary files /dev/null and b/static/img/user-codeTitle.png differ
diff --git a/static/img/user_card_00.png b/static/img/user_card_00.png
index 01601bb..57a8097 100644
Binary files a/static/img/user_card_00.png and b/static/img/user_card_00.png differ
diff --git a/static/img/user_card_02.png b/static/img/user_card_02.png
index f46e38d..ff72f3a 100644
Binary files a/static/img/user_card_02.png and b/static/img/user_card_02.png differ
diff --git a/static/img/welfare_back_00.png b/static/img/welfare_back_00.png
index f6386d2..ecf734a 100644
Binary files a/static/img/welfare_back_00.png and b/static/img/welfare_back_00.png differ
diff --git a/static/img/welfare_back_01.png b/static/img/welfare_back_01.png
index 4d53709..cd518a3 100644
Binary files a/static/img/welfare_back_01.png and b/static/img/welfare_back_01.png differ
diff --git a/static/img/welfare_title.png b/static/img/welfare_title.png
index 2a596ba..41cb6c2 100644
Binary files a/static/img/welfare_title.png and b/static/img/welfare_title.png differ