Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhqg-mini
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhqg
zhqg-mini
Commits
52207aa2
Commit
52207aa2
authored
Oct 16, 2020
by
wangyalan-git
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加
parent
162955ff
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
299 deletions
+113
-299
app.js
app.js
+20
-19
index.js
pages/index/index.js
+6
-4
invite.js
pages/invite/invite.js
+82
-270
invite.json
pages/invite/invite.json
+1
-3
config.js
utils/config.js
+1
-1
http.js
utils/http.js
+3
-2
No files found.
app.js
View file @
52207aa2
...
@@ -18,28 +18,29 @@ App({
...
@@ -18,28 +18,29 @@ App({
overShare
:
function
()
{
overShare
:
function
()
{
//监听路由切换
//监听路由切换
//间接实现全局设置分享内容
//间接实现全局设置分享内容
var
that
=
this
wx
.
onAppRoute
(
function
(
res
)
{
wx
.
onAppRoute
(
function
(
res
)
{
//获取加载的页面
//获取加载的页面
let
pages
=
getCurrentPages
(),
let
pages
=
getCurrentPages
(),
//获取当前页面的对象
//获取当前页面的对象
view
=
pages
[
pages
.
length
-
1
],
view
=
pages
[
pages
.
length
-
1
],
data
;
data
;
if
(
view
)
{
if
(
view
)
{
data
=
view
.
data
;
data
=
view
.
data
;
console
.
log
(
'是否重写分享方法'
,
this
.
globalData
.
userInfo
);
console
.
log
(
'是否重写分享方法'
,
that
.
globalData
.
userInfo
);
if
(
!
data
.
isOverShare
)
{
if
(
!
data
.
isOverShare
)
{
data
.
isOverShare
=
true
;
data
.
isOverShare
=
true
;
view
.
onShareAppMessage
=
function
()
{
view
.
onShareAppMessage
=
function
()
{
//你的分享配置
//你的分享配置
return
{
return
{
title
:
'中厦全供'
,
title
:
'中厦全供'
,
path
:
'/pages/index/index?shareCode='
+
this
.
globalData
.
userInfo
.
shareCode
path
:
'/pages/index/index?shareCode='
+
that
.
globalData
.
userInfo
.
shareCode
};
};
}
}
}
}
}
}
})
})
},
},
globalData
:
{
globalData
:
{
userInfo
:
''
,
userInfo
:
''
,
// 定义全局请求队列
// 定义全局请求队列
...
...
pages/index/index.js
View file @
52207aa2
...
@@ -80,12 +80,14 @@ Page({
...
@@ -80,12 +80,14 @@ Page({
},
},
onShow
:
function
()
{
onShow
:
function
()
{
console
.
log
(
'页面参路径'
,
this
.
options
)
var
that
=
this
wx
.
getSetting
({
wx
.
getSetting
({
success
(
res
)
{
success
(
res
)
{
if
(
!
res
.
authSetting
[
'scope.userInfo'
])
{
if
(
!
res
.
authSetting
[
'scope.userInfo'
])
{
if
(
th
is
.
options
.
shareCode
)
{
if
(
th
at
.
options
.
shareCode
)
{
wx
.
navigateTo
({
wx
.
navigateTo
({
url
:
'/pages/login/login?shareCode='
+
th
is
.
options
.
shareCode
,
url
:
'/pages/login/login?shareCode='
+
th
at
.
options
.
shareCode
,
})
})
}
else
{
}
else
{
wx
.
navigateTo
({
wx
.
navigateTo
({
...
@@ -93,8 +95,8 @@ Page({
...
@@ -93,8 +95,8 @@ Page({
})
})
}
}
}
else
{
}
else
{
if
(
th
is
.
options
.
shareCode
)
{
if
(
th
at
.
options
.
shareCode
)
{
th
is
.
boundParentByShareCode
(
options
.
shareCode
);
// 绑定内容获取
th
at
.
boundParentByShareCode
(
options
.
shareCode
);
// 绑定内容获取
}
}
}
}
}
}
...
...
pages/invite/invite.js
View file @
52207aa2
...
@@ -13,216 +13,9 @@ Page({
...
@@ -13,216 +13,9 @@ Page({
smsCode
:
null
,
smsCode
:
null
,
avatar
:
null
,
avatar
:
null
,
popBox
:
0
,
// 弹窗启动
popBox
:
0
,
// 弹窗启动
inviteTemplate
:
''
},
},
onImgOK
(
e
)
{
this
.
imagePath
=
e
.
detail
.
path
;
this
.
setData
({
image
:
this
.
imagePath
})
if
(
this
.
isSave
)
{
this
.
saveImage
(
this
.
imagePath
);
}
console
.
log
(
'imageok'
,
this
.
data
.
image
)
},
template
()
{
return
{
"width"
:
"200px"
,
"height"
:
"320px"
,
"background"
:
"#f8f8f8"
,
"views"
:
[
{
"type"
:
"rect"
,
"css"
:
{
"background"
:
"#DF001B"
,
"width"
:
"200px"
,
"height"
:
"40px"
,
"top"
:
"0px"
,
"left"
:
"0px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"shadow"
:
""
,
"color"
:
"#DF001B"
}
},
{
"type"
:
"text"
,
"text"
:
"车理狗"
,
"css"
:
{
"color"
:
"#fff"
,
"background"
:
""
,
"width"
:
"200px"
,
"height"
:
"22.88px"
,
"top"
:
"4.999999999999998px"
,
"left"
:
"0px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"borderWidth"
:
""
,
"borderColor"
:
"#000000"
,
"shadow"
:
""
,
"padding"
:
"0px"
,
"fontSize"
:
"16px"
,
"fontWeight"
:
"normal"
,
"maxLines"
:
"2"
,
"lineHeight"
:
"23.088000000000005px"
,
"textStyle"
:
"fill"
,
"textDecoration"
:
"none"
,
"fontFamily"
:
""
,
"textAlign"
:
"center"
}
},
{
"type"
:
"rect"
,
"css"
:
{
"background"
:
"#fff"
,
"width"
:
"200px"
,
"height"
:
"80px"
,
"top"
:
"27px"
,
"left"
:
"0px"
,
"rotate"
:
"0"
,
"borderRadius"
:
"10px"
,
"shadow"
:
""
,
"color"
:
"#fff"
}
},
{
"type"
:
"text"
,
"text"
:
"稀世宅品 欧儿童房灯LED灯卧室灯房间灯具灯饰男孩女孩稀世宅 北欧儿童房灯LED灯卧室灯房间灯具灯饰男孩女孩"
,
"css"
:
{
"color"
:
"#333"
,
"background"
:
"#fff"
,
"width"
:
"180px"
,
"height"
:
"34.788000000000004px"
,
"top"
:
"36px"
,
"left"
:
"10px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"borderWidth"
:
""
,
"borderColor"
:
"#000000"
,
"shadow"
:
""
,
"padding"
:
"0px"
,
"fontSize"
:
"12px"
,
"fontWeight"
:
"normal"
,
"maxLines"
:
"2"
,
"lineHeight"
:
"17.316000000000003px"
,
"textStyle"
:
"fill"
,
"textDecoration"
:
"none"
,
"fontFamily"
:
""
,
"textAlign"
:
"left"
}
},
{
"type"
:
"text"
,
"text"
:
"¥259.00"
,
"css"
:
{
"color"
:
"#DF001B"
,
"background"
:
""
,
"width"
:
"100px"
,
"height"
:
"22.88px"
,
"top"
:
"70px"
,
"left"
:
"7px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"borderWidth"
:
""
,
"borderColor"
:
"#000000"
,
"shadow"
:
""
,
"padding"
:
"0px"
,
"fontSize"
:
"16px"
,
"fontWeight"
:
"normal"
,
"maxLines"
:
"2"
,
"lineHeight"
:
"23.088000000000005px"
,
"textStyle"
:
"fill"
,
"textDecoration"
:
"none"
,
"fontFamily"
:
""
,
"textAlign"
:
"c"
}
},
{
"type"
:
"image"
,
"url"
:
"/images/banner@2x.png"
,
"css"
:
{
"width"
:
"200px"
,
"height"
:
"150px"
,
"top"
:
"93px"
,
"left"
:
"0px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"borderWidth"
:
""
,
"borderColor"
:
"#000000"
,
"shadow"
:
""
,
"mode"
:
"aspectFill"
}
},
// {
// "type": "qrcode",
// "content": "哈哈哈",
// "css": {
// "color": "#000000",
// "background": "#ffffff",
// "width": "50px",
// "height": "50px",
// "top": "254px",
// "left": "33px",
// "rotate": "0",
// "borderRadius": ""
// }
// },
{
"type"
:
"text"
,
"text"
:
"卡车行小程序"
,
"css"
:
{
"color"
:
"#333"
,
"background"
:
""
,
"width"
:
"100px"
,
"height"
:
"17.16px"
,
"top"
:
"262px"
,
"left"
:
"89px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"borderWidth"
:
""
,
"borderColor"
:
"#000000"
,
"shadow"
:
""
,
"padding"
:
"0px"
,
"fontSize"
:
"12px"
,
"fontWeight"
:
"bold"
,
"maxLines"
:
"2"
,
"lineHeight"
:
"17.316000000000003px"
,
"textStyle"
:
"fill"
,
"textDecoration"
:
"none"
,
"fontFamily"
:
""
,
"textAlign"
:
"c"
}
},
{
"type"
:
"text"
,
"text"
:
"长按识别 去逛逛"
,
"css"
:
{
"color"
:
"#999"
,
"background"
:
""
,
"width"
:
"100px"
,
"height"
:
"11.44px"
,
"top"
:
"281.02px"
,
"left"
:
"92px"
,
"rotate"
:
"0"
,
"borderRadius"
:
""
,
"borderWidth"
:
""
,
"borderColor"
:
"#000000"
,
"shadow"
:
""
,
"padding"
:
"0px"
,
"fontSize"
:
"8px"
,
"fontWeight"
:
"bold"
,
"maxLines"
:
"2"
,
"lineHeight"
:
"11.544000000000002px"
,
"textStyle"
:
"fill"
,
"textDecoration"
:
"none"
,
"fontFamily"
:
""
,
"textAlign"
:
""
}
}
]
}
},
// 用户信息
// 用户信息
getUserInfo
()
{
getUserInfo
()
{
var
params
=
{
var
params
=
{
...
@@ -233,48 +26,83 @@ Page({
...
@@ -233,48 +26,83 @@ Page({
console
.
log
(
'用户信息'
,
res
.
result
)
console
.
log
(
'用户信息'
,
res
.
result
)
this
.
setData
({
this
.
setData
({
userInfo
:
res
.
result
,
userInfo
:
res
.
result
,
},
function
()
{
})
this
.
getMiniAppQrcode
()
this
.
getMiniAppQrcode
()
});
},
errCallBack
:
(
err
)
=>
{
wx
.
showToast
({
title
:
'用户信息获取失败'
,
})
}
}
};
};
http
.
request
(
params
);
http
.
request
(
params
);
},
},
// 二维码
// 二维码
getMiniAppQrcode
()
{
getMiniAppQrcode
()
{
var
that
=
this
var
params
=
{
var
params
=
{
url
:
"/wechatCommon/getMiniAppQrcode"
,
url
:
"/wechatCommon/getMiniAppQrcode"
,
method
:
"GET"
,
method
:
"GET"
,
data
:
{},
data
:
{},
callBack
:
(
res
)
=>
{
callBack
:
(
res
)
=>
{
let
img
=
'data:image/png;base64,'
+
res
.
result
let
img
=
'data:image/png;base64,'
+
res
.
result
this
.
send_code
(
img
)
that
.
send_code
(
img
)
// console.log('二维码', img)
}
}
};
};
http
.
request
(
params
);
http
.
request
(
params
);
},
},
//将base64图片转网络图片
//将base64图片转网络图片
send_code
:
function
(
base64data
)
{
send_code
(
code
)
{
const
fsm
=
wx
.
getFileSystemManager
();
/*code是指图片base64格式数据*/
const
FILE_BASE_NAME
=
'tmp_base64src'
;
//声明文件系统
const
[,
format
,
bodyData
]
=
/data:image
\/(\w
+
)
;base64,
(
.*
)
/
.
exec
(
base64data
)
||
[];
const
fs
=
wx
.
getFileSystemManager
();
if
(
!
format
)
{
//随机定义路径名称
console
.
log
(
new
Error
(
'ERROR_BASE64SRC_PARSE'
));
var
times
=
new
Date
().
getTime
();
var
codeimg
=
wx
.
env
.
USER_DATA_PATH
+
'/'
+
times
+
'.png'
;
//将base64图片写入
fs
.
writeFile
({
filePath
:
codeimg
,
data
:
code
.
slice
(
22
),
encoding
:
'base64'
,
success
:
()
=>
{
this
.
setData
({
code
:
codeimg
})
//写入成功了的话,新的图片路径就能用了
this
.
drawImage
()
}
}
const
filePath
=
`
${
wx
.
env
.
USER_DATA_PATH
}
/
${
FILE_BASE_NAME
}
.
${
format
}
`
;
});
const
buffer
=
wx
.
base64ToArrayBuffer
(
bodyData
);
},
fsm
.
writeFile
({
sendCode
()
{
filePath
,
const
fsm
=
wx
.
getFileSystemManager
();
data
:
buffer
,
const
FILE_BASE_NAME
=
'tmp_base64src'
;
encoding
:
'binary'
,
const
[,
format
,
bodyData
]
=
/data:image
\/(\w
+
)
;base64,
(
.*
)
/
.
exec
(
img
)
||
[];
success
()
{
if
(
!
format
)
{
console
.
log
(
"path"
,
filePath
)
reject
(
new
Error
(
'ERROR_BASE64SRC_PARSE'
));
},
}
fail
()
{
const
filePath
=
`
${
wx
.
env
.
USER_DATA_PATH
}
/
${
FILE_BASE_NAME
}
.
${
format
}
`
;
reject
(
new
Error
(
'ERROR_BASE64SRC_WRITE'
));
const
buffer
=
wx
.
base64ToArrayBuffer
(
bodyData
);
},
console
.
log
(
'执行'
)
});
fsm
.
writeFile
({
filePath
,
data
:
buffer
,
encoding
:
'binary'
,
success
()
{
console
.
log
(
'filePath'
,
filePath
)
that
.
setData
({
code
:
filePath
})
that
.
drawImage
()
},
fail
()
{
console
.
log
(
'图片转换失败'
)
reject
(
new
Error
(
'ERROR_BASE64SRC_WRITE'
));
},
complete
()
{
console
.
log
(
'无论图片转换失败'
)
}
})
console
.
log
(
'二维码'
,
res
)
},
},
// 保存图片
// 保存图片
saveImage
(
imagePath
=
''
)
{
saveImage
(
imagePath
=
''
)
{
...
@@ -306,21 +134,7 @@ Page({
...
@@ -306,21 +134,7 @@ Page({
});
});
}
}
},
},
// 获取小程序图片
getInvite
:
function
()
{
var
that
=
this
return
new
Promise
(
resolve
=>
{
api
.
getInvite
({},
{
suc
:
function
(
res
)
{
console
.
log
(
'小程序吗'
,
res
)
that
.
setData
({
smsCode
:
res
.
data
.
data
})
return
resolve
();
}
})
});
},
// 保存图片
// 保存图片
save
:
function
()
{
save
:
function
()
{
let
that
=
this
;
let
that
=
this
;
...
@@ -389,6 +203,7 @@ Page({
...
@@ -389,6 +203,7 @@ Page({
},
},
// 绘制图片
// 绘制图片
drawImage
:
function
()
{
drawImage
:
function
()
{
console
.
log
(
"获取到的数据"
,
this
.
data
.
code
,
this
.
data
.
userInfo
)
// 绘制图片
// 绘制图片
var
that
=
this
var
that
=
this
wx
.
showLoading
({
wx
.
showLoading
({
...
@@ -455,25 +270,25 @@ Page({
...
@@ -455,25 +270,25 @@ Page({
context
.
setFillStyle
(
'#E5E5E5'
)
context
.
setFillStyle
(
'#E5E5E5'
)
context
.
fillText
(
"邀请您使用【中厦全供】"
,
myCanvasWidth
/
2
,
myCanvasHeight
/
2.9
);
context
.
fillText
(
"邀请您使用【中厦全供】"
,
myCanvasWidth
/
2
,
myCanvasHeight
/
2.9
);
console
.
log
(
'二维码'
,
that
.
data
.
code
)
console
.
log
(
'二维码'
,
that
.
data
.
code
)
//
wx.getImageInfo({
wx
.
getImageInfo
({
//
src: that.data.code,
src
:
that
.
data
.
code
,
//
success: function (res) {
success
:
function
(
res
)
{
//
console.log('图片', res)
console
.
log
(
'图片'
,
res
)
//
var smsCode = res.path;
var
smsCode
=
res
.
path
;
//
context.save();
context
.
save
();
//
context.beginPath();
context
.
beginPath
();
//
//先画个圆 前两个参数确定了圆心 (x,y) 坐标 第三个参数是圆的半径 四参数是绘图方向 默认是false,即顺时针
//先画个圆 前两个参数确定了圆心 (x,y) 坐标 第三个参数是圆的半径 四参数是绘图方向 默认是false,即顺时针
//
context.arc(avatarur2_width / 2 + avatarur2_x, avatarur2_heigth / 2 + avatarur2_y, avatarur2_width / 2, 0, Math.PI * 2, false);
context
.
arc
(
avatarur2_width
/
2
+
avatarur2_x
,
avatarur2_heigth
/
2
+
avatarur2_y
,
avatarur2_width
/
2
,
0
,
Math
.
PI
*
2
,
false
);
//
context.clip();
context
.
clip
();
//
context.drawImage(smsCode, avatarur2_x, avatarur2_y, avatarur2_width, avatarur2_heigth);
context
.
drawImage
(
smsCode
,
avatarur2_x
,
avatarur2_y
,
avatarur2_width
,
avatarur2_heigth
);
//
// 必须是https图片
// 必须是https图片
//
context.restore();
context
.
restore
();
//
context.draw(true);
context
.
draw
(
true
);
//
},
},
//
fail: function (err) {
fail
:
function
(
err
)
{
//
console.log('失败', err)
console
.
log
(
'失败'
,
err
)
//
}
}
//
})
})
//定时器作用同上
//定时器作用同上
setTimeout
(
function
()
{
setTimeout
(
function
()
{
wx
.
hideLoading
();
wx
.
hideLoading
();
...
@@ -488,10 +303,7 @@ Page({
...
@@ -488,10 +303,7 @@ Page({
*/
*/
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
this
.
getUserInfo
()
this
.
getUserInfo
()
this
.
setData
({
inviteTemplate
:
this
.
template
()
})
console
.
log
(
'inviteTemplate'
,
this
.
data
.
inviteTemplate
)
},
},
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
...
...
pages/invite/invite.json
View file @
52207aa2
{
{
"usingComponents"
:
{
"usingComponents"
:
{},
"painter"
:
"/components/painter/painter"
},
"navigationBarTitleText"
:
"邀请海报"
,
"navigationBarTitleText"
:
"邀请海报"
,
"navigationBarBackgroundColor"
:
"#000000"
,
"navigationBarBackgroundColor"
:
"#000000"
,
"navigationBarTextStyle"
:
"white"
"navigationBarTextStyle"
:
"white"
...
...
utils/config.js
View file @
52207aa2
var
domain
=
"http://192.168.31.11
0
:8086/capi"
;
//统一接口域名,测试环境
var
domain
=
"http://192.168.31.11
3
:8086/capi"
;
//统一接口域名,测试环境
exports
.
domain
=
domain
;
exports
.
domain
=
domain
;
utils/http.js
View file @
52207aa2
...
@@ -91,7 +91,7 @@ var getToken = function () {
...
@@ -91,7 +91,7 @@ var getToken = function () {
wx
.
setStorageSync
(
'token'
,
''
);
wx
.
setStorageSync
(
'token'
,
''
);
}
else
{
}
else
{
wx
.
setStorageSync
(
'token'
,
'bearer'
+
result
.
access_token
);
//把token存入缓存,请求接口数据时要用
wx
.
setStorageSync
(
'token'
,
'bearer'
+
result
.
access_token
);
//把token存入缓存,请求接口数据时要用
this
.
getUserInfo
()
getUserInfo
()
}
}
var
globalData
=
getApp
().
globalData
;
var
globalData
=
getApp
().
globalData
;
globalData
.
isLanding
=
false
;
globalData
.
isLanding
=
false
;
...
@@ -112,10 +112,11 @@ function getUserInfo() {
...
@@ -112,10 +112,11 @@ function getUserInfo() {
data
:
{},
data
:
{},
callBack
:
(
res
)
=>
{
callBack
:
(
res
)
=>
{
console
.
log
(
'用户信息'
,
res
.
result
)
console
.
log
(
'用户信息'
,
res
.
result
)
var
app
=
getApp
();
app
.
globalData
.
userInfo
=
res
.
result
app
.
globalData
.
userInfo
=
res
.
result
}
}
};
};
http
.
request
(
params
);
request
(
params
);
}
}
// 更新用户头像昵称
// 更新用户头像昵称
function
updateUserInfo
()
{
function
updateUserInfo
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment