Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	pages/myinformation/myinformation.vue
This commit is contained in:
闫晓茹 2023-09-20 14:22:42 +08:00
commit 02405cf3f6
13 changed files with 2124 additions and 184 deletions

View File

@ -0,0 +1,733 @@
export default{
data(){
return{
system_info:{}, //system info
canvas_width:0, //canvas width px
canvas_height:0, //canvas height px
ctx:null, //canvas object
canvas_id:null, //canvas id
hidden:false,//Whether to hide canvas
scale:1,//canvas scale
r_canvas_scale:1,
if_ctx:true
}
},
methods:{
/**
* save r-canvas.vue object
* @param {Object} that
*/
// saveThis(that){
// rCanvasThis = that
// },
/**
* Draw round rect text
* @param {Object} config
* @param {Number} config.x x坐标
* @param {Number} config.y y坐标
* @param {Number} config.w 宽度
* @param {Number} config.h 高度
* @param {Number} config.radius 圆角弧度
* @param {String} config.fill_color 矩形颜色
*/
fillRoundRect(config) {
return new Promise((resolve,reject)=>{
let x = this.compatibilitySize(parseFloat(config.x)*this.scale)
let y = this.compatibilitySize(parseFloat(config.y)*this.scale)
let w = this.compatibilitySize(parseFloat(config.w)*this.scale)
let h = this.compatibilitySize(parseFloat(config.h)*this.scale)
let radius = config.radius?parseFloat(config.radius)*this.scale:10*this.scale
let fill_color = config.fill_color || "black"
// The diameter of the circle must be less than the width and height of the rectangle
if (2 * radius > w || 2 * radius > h) {
reject("The diameter of the circle must be less than the width and height of the rectangle")
return false;
}
this.ctx.save();
this.ctx.translate(x, y);
//
this.drawRoundRectPath({
w: w,
h: h,
radius: radius
});
this.ctx.fillStyle = fill_color
this.ctx.fill();
this.ctx.restore();
resolve()
})
},
/**
* Draws the sides of a rounded rectangle
* @param {Object} config
* @param {Number} config.w 宽度
* @param {Number} config.h 高度
* @param {Number} config.radius 圆角弧度
*/
drawRoundRectPath(config) {
this.ctx.beginPath(0);
this.ctx.arc(config.w - config.radius, config.h - config.radius, config.radius, 0, Math.PI / 2);
this.ctx.lineTo(config.radius, config.h);
this.ctx.arc(config.radius, config.h - config.radius, config.radius, Math.PI / 2, Math.PI);
this.ctx.lineTo(0, config.radius);
this.ctx.arc(config.radius, config.radius, config.radius, Math.PI, Math.PI * 3 / 2);
this.ctx.lineTo(config.w - config.radius, 0);
this.ctx.arc(config.w - config.radius, config.radius, config.radius, Math.PI * 3 / 2, Math.PI * 2);
this.ctx.lineTo(config.w, config.h - config.radius);
this.ctx.closePath();
},
/**
* Draw special Text,line wrapping is not supported
* @param {Object} config
* @param {String} config.text 文字
* @param {Number} config.x x坐标
* @param {Number} config.y y坐标
* @param {String} config.font_color 文字颜色
* @param {String} config.font_family 文字字体
* @param {Number} config.font_size 文字大小px
*/
drawSpecialText(params){
let general = params.general
let list = params.list
return new Promise(async (resolve,reject)=>{
if(!general){
reject("general cannot be empty:101")
return;
}else if(list && list.length>0){
for(let i in list){
if(i != 0){
let font_size = list[i-1].font_size?parseFloat(list[i-1].font_size):20
this.ctx.setFontSize(font_size)
general.x = parseFloat(general.x) + this.ctx.measureText(list[i-1].text).width
}
list[i].x = general.x
list[i].y = general.y + (list[i].margin_top?parseFloat(list[i].margin_top):0)
await this.drawText(list[i])
}
resolve()
}else{
reject("The length of config arr is less than 0")
return;
}
})
},
/**
* array delete empty
* @param {Object} arr
*/
arrDeleteEmpty(arr){
let newArr = []
for(let i in arr){
if(arr[i]){
newArr.push(arr[i])
}
}
return newArr
},
/**
* Draw Text,support line
* @param {Object} config
* @param {String} config.text 文字
* @param {Number} config.max_width 文字最大宽度大于宽度自动换行
* @param {Number} config.line_height 文字上下行间距
* @param {Number} config.x x坐标
* @param {Number} config.y y坐标
* @param {String} config.font_color 文字颜色
* @param {String} config.font_family 文字字体 默认值Arial
* @param {String} config.text_align 文字对齐方式left/center/right
* @param {Number} config.font_size 文字大小px
* @param {Boolean} config.line_through_height 中划线大小
* @param {Boolean} config.line_through_color 中划线颜色
* @param {String} config.font_style 规定文字样式
* @param {String} config.font_variant 规定字体变体
* @param {String} config.font_weight 规定字体粗细
* @param {String} config.line_through_cap 线末端类型
* @param {String} config.line_clamp 最大行数
* @param {String} config.line_clamp_hint 超过line_clamp后尾部显示的自定义标识 ...
* @param {String} config.is_line_break 是否开启换行符换行
*
*/
drawText(config,configuration = {}){
configuration['line_num'] = configuration.line_num?configuration.line_num:0
configuration['text_width'] = configuration.text_width?configuration.text_width:0
return new Promise(async (resolve,reject)=>{
if(config.text){
let draw_width = 0,draw_height = 0,draw_x = config.x,draw_y = config.y
let font_size = config.font_size?(parseFloat(config.font_size)*this.scale):(20*this.scale)
let font_color = config.font_color || "#000"
let font_family = config.font_family || "Arial"
let line_height = config.line_height || config.font_size || 20
let text_align = config.text_align || "left"
let font_weight = config.font_weight || "normal"
let font_variant = config.font_variant || "normal"
let font_style = config.font_style || "normal"
let line_clamp_hint = config.line_clamp_hint || '...'
let lineBreakJoinText = ""
let max_width = config.max_width?parseFloat(config.max_width)*this.scale:0
// checkout is line break
if(config.is_line_break){
let splitTextArr = config.text.split(/[\n]/g)
if(splitTextArr && splitTextArr.length > 0){
let newSplitTextArr = this.arrDeleteEmpty(splitTextArr)
if(newSplitTextArr && newSplitTextArr.length > 0){
lineBreakJoinText = newSplitTextArr.slice(1).join("\n")
config.text = newSplitTextArr[0]
}else{
reject("Text cannot be empty:103")
return
}
}else{
reject("Text cannot be empty:102")
return
}
}
this.ctx.setFillStyle(font_color) // color
this.ctx.textAlign = text_align;
this.ctx.font = `${font_style} ${font_variant} ${font_weight} ${parseInt(font_size)}px ${font_family}`
if(configuration.text_width >= this.ctx.measureText(config.text).width){
draw_width = configuration.text_width
}else if(max_width > 0){
draw_width = max_width < this.ctx.measureText(config.text).width ? this.resetCompatibilitySize(max_width) : this.resetCompatibilitySize(this.ctx.measureText(config.text).width)
}else{
draw_width = this.ctx.measureText(config.text).width
}
configuration.text_width = draw_width / this.scale
if( max_width && this.compatibilitySize(this.ctx.measureText(config.text).width) > this.compatibilitySize(max_width)){
let current_text = ""
let text_arr = config.text.split("")
for(let i in text_arr){
if( this.compatibilitySize(this.ctx.measureText(current_text+text_arr[i]).width) > this.compatibilitySize(max_width) ){
// Hyphenation that is greater than the drawable width continues to draw
if(config.line_clamp && parseInt(config.line_clamp) == 1){
// Subtracting the current_text tail width from the line_clamp_hint width
let current_text_arr = current_text.split('')
let json_current_text = ''
while(true){
current_text_arr = current_text_arr.slice(1)
json_current_text = current_text_arr.join('')
if(this.compatibilitySize(this.ctx.measureText(json_current_text).width) <= this.compatibilitySize(this.ctx.measureText(line_clamp_hint).width)){
current_text = current_text.replace(json_current_text,'')
break;
}
}
configuration.line_num += 1
this.ctx.setFontSize(parseInt(this.compatibilitySize(font_size))) // font size
this.ctx.fillText(current_text + line_clamp_hint, this.compatibilitySize(parseFloat(config.x)*this.scale), this.compatibilitySize(parseFloat(config.y)*this.scale));
}else{
configuration.line_num += 1
this.ctx.setFontSize(parseInt(this.compatibilitySize(font_size))) // font size
this.ctx.fillText(current_text, this.compatibilitySize(parseFloat(config.x)*this.scale), this.compatibilitySize(parseFloat(config.y)*this.scale));
config.text = text_arr.slice(i).join("")
config.y = config.y + line_height
if(config.line_clamp){
config.line_clamp = parseInt(config.line_clamp) - 1
}
await this.drawText(config,configuration)
}
break;
}else{
current_text = current_text+text_arr[i]
}
}
}else{
if(config.line_through_height){
let x = parseFloat(config.x)*this.scale
let w
let y = parseFloat(config.y)*this.scale - (font_size / 2.6)
if(text_align == "left"){
w = this.ctx.measureText(config.text).width/1.1 + parseFloat(config.x)*this.scale
}else if(text_align == "right"){
w = parseFloat(config.x)*this.scale - this.ctx.measureText(config.text).width/1.1
}else if(text_align == "center"){
x = parseFloat(config.x)*this.scale - this.ctx.measureText(config.text).width / 1.1 / 2
w = parseFloat(config.x)*this.scale + this.ctx.measureText(config.text).width / 1.1 / 2
}
this.drawLineTo({
x:x,
y:y,
w:w,
h:y,
line_width:config.line_through_height,
line_color:config.line_through_color,
line_cap:config.line_through_cap
})
}
configuration.line_num += 1
this.ctx.setFontSize(parseInt(this.compatibilitySize(font_size))) // font size
this.ctx.fillText(config.text, this.compatibilitySize(parseFloat(config.x)*this.scale), this.compatibilitySize(parseFloat(config.y)*this.scale));
if(config.line_clamp){
config.line_clamp = parseInt(config.line_clamp) - 1
}
}
if(lineBreakJoinText){
await this.drawText({...config,text:lineBreakJoinText,y:config.y + line_height},configuration)
}
draw_height = config.font_size * configuration.line_num
draw_width = configuration.text_width
resolve({draw_width,draw_height,draw_x,draw_y})
}else{
reject("Text cannot be empty:101")
}
})
},
/**
* Draw Line
* @param {Object} config
* @param {Object} config.x x坐标
* @param {Object} config.y y坐标
* @param {Object} config.w 线的宽度
* @param {Object} config.h 线的高度
* @param {Object} config.line_width 线的宽度
* @param {Object} config.line_color 线条颜色
*/
drawLineTo(config){
let x = this.compatibilitySize(config.x)
let y = this.compatibilitySize(config.y)
let w = this.compatibilitySize(config.w)
let h = this.compatibilitySize(config.h)
let line_width = config.line_width?parseFloat(config.line_width)*this.scale:1*this.scale
let line_color = config.line_color || "black"
let line_cap = config.line_cap || "butt"
this.ctx.beginPath()
this.ctx.lineCap = line_cap
this.ctx.lineWidth = line_width
this.ctx.strokeStyle = line_color
this.ctx.moveTo(x,y)
this.ctx.lineTo(w,h)
this.ctx.stroke()
},
/**
* Compatibility px
* @param {Object} size
*/
compatibilitySize(size) {
let canvasSize = (parseFloat(size) / 750) * this.system_info.windowWidth
canvasSize = parseFloat(canvasSize * 2)
return canvasSize
},
/**
* Restore compatibility px
* @param {Object} size
*/
resetCompatibilitySize(size) {
let canvasSize = (parseFloat(size/2)/this.system_info.windowWidth) * 750
return canvasSize
},
/**
* Init canvas
*/
init(config){
return new Promise(async (resolve,reject)=>{
if(!config.canvas_id){
reject("Canvas ID cannot be empty, please refer to the usage example")
return;
}
this.hidden = config.hidden
this.canvas_id = config.canvas_id
let system_info = await uni.getSystemInfoSync()
this.system_info = system_info
this.scale = config.scale&&parseFloat(config.scale)>0?parseInt(config.scale):1
this.canvas_width = (config.canvas_width ? this.compatibilitySize(config.canvas_width) : system_info.windowWidth) * this.scale
this.canvas_height = (config.canvas_height ? this.compatibilitySize(config.canvas_height) : system_info.windowHeight) * this.scale,
this.r_canvas_scale = 1/this.scale
this.ctx = uni.createCanvasContext(this.canvas_id,this)
this.setCanvasConfig({
global_alpha:config.global_alpha?parseFloat(config.global_alpha):1,
backgroundColor:config.background_color?config.background_color:"#fff"
})
resolve()
})
},
/**
* clear canvas all path
*/
clearCanvas(){
return new Promise(async (resolve,reject)=>{
if(!this.ctx){
reject("canvas is not initialized:101")
return
}else{
this.ctx.clearRect(0,0,parseFloat(this.canvas_width)*this.scale,parseFloat(this.canvas_height)*this.scale)
await this.draw()
resolve()
}
})
},
/**
* Set canvas config
* @param {Object} config
*/
setCanvasConfig(config){
this.ctx.globalAlpha = config.global_alpha
this.ctx.fillStyle = config.backgroundColor
this.ctx.fillRect(0, 0, parseFloat(this.canvas_width)*this.scale, parseFloat(this.canvas_height)*this.scale)
},
/**
* set canvas width
* @param {Object} width
*/
setCanvasWidth(width){
if(!width){
// uni.showToast({
// title:'setCanvasWidthwidth error',
// icon:'none'
// })
}
this.canvas_width = this.compatibilitySize(parseFloat(width)) * this.scale
this.ctx.width = this.canvas_width
},
/**
* set canvas height
* @param {Object} height
*/
setCanvasHeight(height){
if(!height){
// uni.showToast({
// title:'setCanvasWidthheight error',
// icon:'none'
// })
}
this.canvas_height = this.compatibilitySize(parseFloat(height)) * this.scale
this.ctx.height = this.canvas_height
},
/**
* Draw to filepath
*/
draw(callback){
return new Promise((resolve,reject)=>{
let stop = setTimeout(()=>{
this.ctx.draw(false,setTimeout(()=>{
uni.canvasToTempFilePath({
canvasId: this.canvas_id,
quality: 1,
success: (res)=>{
resolve(res)
callback && callback(res)
},
fail:(err)=>{
reject(JSON.stringify(err)|| "Failed to generate poster:101")
}
},this)
},300))
clearTimeout(stop)
},300)
})
},
/**
* draw rect
* @param {Number} config.x x坐标
* @param {Number} config.y y坐标
* @param {Number} config.w 图形宽度(px)
* @param {Number} config.h 图形高度(px)
* @param {Number} config.color 图形颜色
* @param {Number} config.is_radius 是否开启圆图1.1.6及以下版本废弃请使用border_radius
* @param {Number} config.border_width 边框大小
* @param {Number} config.border_color 边框颜色
*
*/
drawRect(config){
return new Promise(async (resolve,reject)=>{
if(!config.border_width || config.border_width <=0){
config.border_width = 0
}else{
config.border_width = parseFloat(config.border_width)
}
if(parseFloat(config.border_width) > 0){
let sub_config = JSON.parse(JSON.stringify(config))
sub_config.border_width = 0
sub_config.w = config.w + config.border_width
sub_config.h = config.h + config.border_width
sub_config.color = config.border_color || 'black'
if(sub_config.border_radius){
sub_config.border_radius = parseFloat(sub_config.border_radius) + parseFloat(config.border_width) / 2
}
await this.drawRect(sub_config)
}
let color = config.color || 'white'
config.x = (parseFloat(config.x) + config.border_width / 2)
config.y = (parseFloat(config.y) + config.border_width / 2)
config['color'] = color
this.ctx.fillStyle = color;
if(config.is_radius || config.border_radius){
this.setNativeBorderRadius(config)
this.ctx.fill()
}else{
this.ctx.fillRect(this.compatibilitySize(config.x*this.scale),this.compatibilitySize(config.y*this.scale),this.compatibilitySize(parseFloat(config.w)*this.scale),this.compatibilitySize(parseFloat(config.h)*this.scale))
}
resolve()
})
},
/**
* Draw image
* @param {Object} config
* @param {String} config.url 图片链接
* @param {Number} config.x x坐标
* @param {Number} config.y y坐标
* @param {Number} config.w 图片宽度(px)
* @param {Number} config.h 图片高度(px)
* @param {Number} config.border_width 边大小
* @param {Number} config.border_color 边颜色
* @param {Number} config.is_radius 是否开启圆图1.1.6及以下版本废弃请使用border_radius
* @param {Number} config.border_radius 圆角弧度
*/
drawImage(config){
return new Promise(async (resolve,reject)=>{
if(config.url){
let type = 0 // 1、network image 2、native image 3、base64 image
let image_url
let reg = /^https?/ig;
if(reg.test(config.url)){
type = 1
}else{
if((config.url.indexOf("data:image/png;base64") != -1) || config.url.indexOf("data:image/jpeg;base64") != -1 || config.url.indexOf("data:image/gif;base64") != -1){
type = 3
}else{
type = 2
}
}
if(type == 1){
// network image
await this.downLoadNetworkFile(config.url).then(res=>{ // two function
image_url = res
}).catch(err=>{
reject(err)
return;
})
}else if(type == 2){
// native image
const imageInfoResult = await uni.getImageInfo({
src: config.url
});
try{
if(imageInfoResult.length <= 1){
reject(imageInfoResult[0].errMsg + ':404')
return
}
}catch(e){
reject(e+':500')
return
}
let base64 = await this.urlToBase64({url:imageInfoResult[1].path})
// #ifdef MP-WEIXIN
await this.base64ToNative({url:base64}).then(res=>{
image_url = res
}).catch(err=>{
reject(JSON.stringify(err)+":501")
return;
})
// #endif
// #ifndef MP-WEIXIN
image_url = base64
// #endif
}else if(type == 3){
// #ifdef MP-WEIXIN
await this.base64ToNative({url:config.url}).then(res=>{
image_url = res
}).catch(err=>{
reject(JSON.stringify(err)+":500")
return;
})
// #endif
// #ifndef MP-WEIXIN
image_url = config.url
// #endif
}else{
reject("Other Type Errors:101")
return
}
if(config.border_width){
let border_radius = 0
if(config.border_radius){
let multiple = config.w / config.border_radius
border_radius = (parseFloat(config.w) + parseFloat(config.border_width)) / multiple
}
// drawRect
await this.drawRect({
x:parseFloat(config.x) - parseFloat(config.border_width)/2,
y:parseFloat(config.y) - parseFloat(config.border_width)/2,
w:parseFloat(config.w) + parseFloat(config.border_width),
h:parseFloat(config.h) + parseFloat(config.border_width),
color:config.border_color,
border_radius:border_radius,
border_width:config.border_width,
is_radius:config.is_radius
})
}
if(config.border_radius){
config.color = config.color?config.color:'rgba(0,0,0,0)'
// 圆角有白边,+0.5的误差
config.w = config.w + 0.3
config.h = config.h + 0.3
this.setNativeBorderRadius(config)
}else if(config.is_radius){
//已废弃 is_radius
this.ctx.setStrokeStyle("rgba(0,0,0,0)")
this.ctx.save()
this.ctx.beginPath()
this.ctx.arc(this.compatibilitySize(parseFloat(config.x)*this.scale+parseFloat(config.w)*this.scale/2), this.compatibilitySize(parseFloat(config.y)*this.scale+parseFloat(config.h)*this.scale/2), this.compatibilitySize(parseFloat(config.w)*this.scale/2), 0, 2 * Math.PI, false)
this.ctx.stroke();
this.ctx.clip()
}
await this.ctx.drawImage(image_url,this.compatibilitySize(parseFloat(config.x)*this.scale),this.compatibilitySize(parseFloat(config.y)*this.scale),this.compatibilitySize(parseFloat(config.w)*this.scale),this.compatibilitySize(parseFloat(config.h)*this.scale))
this.ctx.restore() //Restore previously saved drawing context
resolve()
}else{
let err_msg = "Links cannot be empty:101"
reject(err_msg)
}
})
},
/**
* base64 to native available path
* @param {Object} config
*/
base64ToNative(config){
return new Promise((resolve,reject)=>{
let fileName = new Date().getTime()
var filePath = `${wx.env.USER_DATA_PATH}/${fileName}_rCanvas.png`
wx.getFileSystemManager().writeFile({
filePath: filePath,
data: config.url.replace(/^data:\S+\/\S+;base64,/, ''),
encoding: 'base64',
success: function() {
resolve(filePath)
},
fail: function(error) {
reject(error)
}
})
})
},
/**
* native url to base64
* @param {Object} config
*/
urlToBase64(config){
return new Promise(async (resolve,reject)=>{
if (typeof window != 'undefined') {
await this.downLoadNetworkFile(config.url).then(res=>{ // two function
resolve(res)
}).catch(err=>{
reject(err)
})
}else if (typeof plus != 'undefined') {
plus.io.resolveLocalFileSystemURL(config.url,(obj)=>{
obj.file((file)=>{
let fileReader = new plus.io.FileReader()
fileReader.onload = (res)=>{
resolve(res.target.result)
}
fileReader.onerror = (err)=>{
reject(err)
}
fileReader.readAsDataURL(file)
}, (err)=>{
reject(err)
})
},(err)=>{
reject(err)
})
}else if(typeof wx != 'undefined'){
wx.getFileSystemManager().readFile({
filePath: config.url,
encoding: 'base64',
success: function(res) {
resolve('data:image/png;base64,' + res.data)
},
fail: function(error) {
reject(error)
}
})
}
})
},
setNativeBorderRadius(config){
let border_radius = config.border_radius?(parseFloat(config.border_radius)*this.scale):(20*this.scale)
if ((parseFloat(config.w)*this.scale) < 2 * border_radius) border_radius = (parseFloat(config.w)*this.scale) / 2;
if ((parseFloat(config.h)*this.scale) < 2 * border_radius) border_radius = (parseFloat(config.h)*this.scale) / 2;
this.ctx.beginPath();
this.ctx.moveTo(this.compatibilitySize((parseFloat(config.x)*this.scale) + border_radius), this.compatibilitySize((parseFloat(config.y)*this.scale)));
this.ctx.arcTo(this.compatibilitySize((parseFloat(config.x)*this.scale) + (parseFloat(config.w)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale)), this.compatibilitySize((parseFloat(config.x)*this.scale) + (parseFloat(config.w)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale) + (parseFloat(config.h)*this.scale)), this.compatibilitySize(border_radius));
this.ctx.arcTo(this.compatibilitySize((parseFloat(config.x)*this.scale) + (parseFloat(config.w)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale) + (parseFloat(config.h)*this.scale)), this.compatibilitySize((parseFloat(config.x)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale) + (parseFloat(config.h)*this.scale)), this.compatibilitySize(border_radius));
this.ctx.arcTo((this.compatibilitySize(parseFloat(config.x)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale) + (parseFloat(config.h)*this.scale)), this.compatibilitySize((parseFloat(config.x)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale)), this.compatibilitySize(border_radius));
this.ctx.arcTo(this.compatibilitySize((parseFloat(config.x)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale)), this.compatibilitySize((parseFloat(config.x)*this.scale) + (parseFloat(config.w)*this.scale)), this.compatibilitySize((parseFloat(config.y)*this.scale)), this.compatibilitySize(border_radius));
this.ctx.closePath();
this.ctx.strokeStyle = config.color || config.border_color || 'rgba(0,0,0,0)'; // 设置绘制边框的颜色
this.ctx.stroke();
this.ctx.save()
this.ctx.clip();
},
/**
* Download network file
* @param {Object} url : download url
*/
downLoadNetworkFile(url){
return new Promise((resolve,reject)=>{
uni.downloadFile({
url,
success:(res)=>{
if(res.statusCode == 200){
resolve(res.tempFilePath)
}else{
reject("Download Image Fail:102")
}
},
fail:(err)=>{
reject("Download Image Fail:101")
}
})
})
},
/**
* Save image to natice
* @param {Object} filePath native imageUrl
*/
saveImage(filePath){
return new Promise((resolve,reject)=>{
if(!filePath){
reject("FilePath cannot be null:101")
return;
}
// #ifdef H5
var createA = document.createElement("a");
createA.download = filePath;
createA.href = filePath;
document.body.appendChild(createA);
createA.click();
createA.remove();
resolve()
// #endif
// #ifndef H5
uni.saveImageToPhotosAlbum({
filePath: filePath,
success:(res)=>{
resolve(res)
},
fail:(err)=>{
reject(err)
}
})
// #endif
})
}
}
}

View File

@ -0,0 +1,26 @@
<template>
<view>
<view class="r-canvas-component" :style="{width:canvas_width/scale+'px',height:canvas_height/scale+'px'}" :class="{'hidden':hidden}">
<canvas class="r-canvas" v-if="canvas_id" :canvas-id="canvas_id" :id="canvas_id" :style="{width:canvas_width+'px',height:canvas_height+'px','transform': `scale(${r_canvas_scale})`}"></canvas>
</view>
</view>
</template>
<script>
import rCanvasJS from "./r-canvas.js"
export default {
mixins:[rCanvasJS]
}
</script>
<style>
.r-canvas{
transform-origin: 0 0;
}
.r-canvas-component{
overflow: hidden;
}
.r-canvas-component.hidden{
position: fixed;
top:-5000upx;
}
</style>

View File

@ -1,19 +1,16 @@
{
"name": "xinelu-applet-ui",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://101.200.89.70:3000/jihan/xinelu-applet-ui.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"uview-ui": "^1.8.8"
}
"dependencies": {
"uview-ui": "^1.8.8"
},
"id": "r-canvas",
"name": "海报生成随心所欲绘制样式原生canvas方法的二次封装自定义函数持续更新",
"version": "1.3.1",
"description": "图片不失帧保留原有画质canvas方法扩展暴露原生实例可自行扩展最好用的canvas插件",
"keywords": [
"canvas",
"画布生成图片",
"绘制图片",
"商品海报",
"朋友圈海报"
]
}

View File

@ -46,7 +46,16 @@
"navigationBarTitleText": "优惠券",
"enablePullDownRefresh": false
}
}]
} ,{
"path" : "healthybeans/healthybeans",
"style" :
{
"navigationBarTitleText": "健康豆",
"enablePullDownRefresh": false
}
}
]
}],
"globalStyle": {

View File

@ -1,180 +1,178 @@
<template>
<view class="app">
<view class="topbanner">
<view class="title">
我的
</view>
<image src="../../static/pages/userbanner.png" mode="" class="userbanner"></image>
<image src="../../static/headsculpture.png" mode="" class="headsculpture"></image>
<view class="namesigning">
<span class="name">
张三
</span>
<view class="signing">
未签约
</view>
</view>
<view class="phone">
17869283647
</view>
<view class="switch btn">
切换家庭成员
</view>
<view class="manage btn" @click="gomanagefamily">
管理家庭成员
</view>
<view class="Threecategories">
<view class="item" @tap="goBehaviorpoints">
<view class="number">
0
</view>
<view class="text" >
行为积分
</view>
</view>
<view class="item">
<view class="number">
0
</view>
<view class="text">
健康豆
</view>
</view>
<view class="item" @tap='gocoupon'>
<view class="number">
0
</view>
<view class="text">
优惠券
</view>
</view>
<view class="app">
<view class="topbanner">
<!-- <view class="title">
我的
</view> -->
<image src="../../static/pages/userbanner.png" mode="" class="userbanner"></image>
<image src="../../static/headsculpture.png" mode="" class="headsculpture"></image>
<view class="namesigning">
<span class="name">
张三
</span>
<view class="signing">
未签约
</view>
</view>
<view class="myorder">
<view class="title">
我的订单
</view>
<view class="righttitle">
查看全部
<image src="../../static/huijiantou.png" mode=""></image>
</view>
<view class="orderStatus">
<view class="item">
<image src="../../static/pages/daifukuan.png" mode=""></image>
<view class="text">
待付款
</view>
</view>
<view class="item">
<image src="../../static/pages/daishouhuo.png" mode=""></image>
<view class="text">
待收货
</view>
</view>
<view class="item">
<image src="../../static/pages/daipingjia.png" mode=""></image>
<view class="text">
待评价
</view>
</view>
<view class="item">
<image src="../../static/pages/yiwancheng.png" mode=""></image>
<view class="text">
已完成
</view>
</view>
</view>
<view class="phone">
17869283647
</view>
<view class="myorder">
<view class="title">
常用功能
</view>
<view class="orderStatus">
<view class="item">
<image src="../../static/pages/jiankangdangan.png" mode=""></image>
<view class="text">
健康档案
</view>
<view class="switch btn">
切换家庭成员
</view>
<view class="manage btn" @click="gomanagefamily">
管理家庭成员
</view>
<view class="Threecategories">
<view class="item">
<view class="number">
0
</view>
<view class="item">
<image src="../../static/pages/wodeyuyue.png" mode=""></image>
<view class="text">
我的预约
</view>
<view class="text">
行为积分
</view>
<view class="item">
<image src="../../static/pages/fuwupingjia.png" mode=""></image>
<view class="text">
服务评价
</view>
</view>
<view class="item" @tap='gohealthybeans'>
<view class="number">
0
</view>
<view class="text">
健康豆
</view>
<view class="item"></view>
</view>
</view>
<view class="myorder titles">
<view class="title">
护理服务订单
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
<view class="myorder titles">
<view class="title">
专家咨询订单
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
<view class="myorder titles">
<view class="title">
签约信息
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
<view class="myorder titles">
<view class="title">
退出登录
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
<view class="item" @tap='gocoupon'>
<view class="number">
0
</view>
<view class="text">
优惠券
</view>
</view>
</view>
</view>
</template>
<view class="myorder">
<view class="title">
我的订单
</view>
<view class="righttitle">
查看全部
<image src="../../static/huijiantou.png" mode=""></image>
</view>
<view class="orderStatus">
<view class="item">
<image src="../../static/pages/daifukuan.png" mode=""></image>
<view class="text">
待付款
</view>
</view>
<view class="item">
<image src="../../static/pages/daishouhuo.png" mode=""></image>
<view class="text">
待收货
</view>
</view>
<view class="item">
<image src="../../static/pages/daipingjia.png" mode=""></image>
<view class="text">
待评价
</view>
</view>
<view class="item">
<image src="../../static/pages/yiwancheng.png" mode=""></image>
<view class="text">
已完成
</view>
</view>
</view>
</view>
<view class="myorder">
<view class="title">
常用功能
</view>
<view class="orderStatus">
<view class="item">
<image src="../../static/pages/jiankangdangan.png" mode=""></image>
<view class="text">
健康档案
</view>
</view>
<view class="item">
<image src="../../static/pages/wodeyuyue.png" mode=""></image>
<view class="text">
我的预约
</view>
</view>
<view class="item">
<image src="../../static/pages/fuwupingjia.png" mode=""></image>
<view class="text">
服务评价
</view>
</view>
<view class="item"></view>
</view>
</view>
<view class="myorder titles">
<view class="title">
护理服务订单
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
<view class="myorder titles">
<view class="title">
专家咨询订单
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
<view class="myorder titles">
<view class="title">
签约信息
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
<view class="myorder titles">
<view class="title">
退出登录
</view>
<view class="righttitle">
<image src="../../static/huijiantou.png" mode=""></image>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
<script>
export default {
data() {
return {
};
};
},
methods: {
gomanagefamily() {
uni.navigateTo({
url: '/pagesB/managefamily/managefamily'
})
},
gocoupon() {
uni.navigateTo({
url: '/pagesB/coupon/coupon'
})
},
gohealthybeans() {
uni.navigateTo({
url: '/pagesB/healthybeans/healthybeans'
})
},
methods: {
goBehaviorpoints(){
uni.navigateTo({
url: '/pagesB/Behaviorpoints/Behaviorpoints'
})
},
gomanagefamily() {
uni.navigateTo({
url: '/pagesB/managefamily/managefamily'
})
},
gocoupon() {
uni.navigateTo({
url: '/pagesB/coupon/coupon'
})
},
}
}
</script>
<style lang="scss">
@import './myinformation.scss'
</style>
}
</script>
<style lang="scss">
@import './myinformation.scss'
</style>

View File

@ -0,0 +1,520 @@
.app {
padding:30rpx 0 10rpx ;
.masks {
z-index: 999;
}
.noorder {
margin-top: 20%;
}
.information {
width: 70%;
height: 400rpx;
margin: 50% auto;
background: #FFFFFF;
border-radius: 30rpx;
text-align: center;
color: #FFFFFF;
position: relative;
.determine,
.cancel {
width: 200rpx;
height: 70rpx;
border-radius: 26rpx;
font-size: 34rpx;
line-height: 70rpx;
position: absolute;
top: 74%;
}
.determine {
background: #4C7BC9;
right: 36rpx;
}
.cancel {
background: #C5BFBF;
left: 36rpx;
}
.title {
font-size: 42rpx;
margin-top: 40rpx;
color: #000000;
}
image {
width: 100rpx;
height: 100rpx;
margin: 10% 0 0 0;
}
}
.close {
width: 31rpx;
height: 31rpx;
position: absolute;
top: 2%;
right: 2%;
z-index: 999;
}
::v-deep .r-canvas {
width: 600rpx !important;
height: 1100rpx !important;
margin: 0 auto;
z-index: -1;
}
::v-deep .r-canvas-component {
width: 760rpx !important;
height: 1100rpx !important;
margin: 0 auto;
z-index: -1;
}
::v-deep .u-mode-center-box {
background: none !important;
}
::v-deep .u-icon--right{
background-color: #fff;
border-radius: 50%;
padding: 6rpx;
// width: 40rpx !important;
// height: 40rpx !important;
}
::v-deep .u-iconfont {
// position: absolute !important;
// left:50% !important;
// top:50% !important;
// transform: translate(-50%,-50%) !important;
}
::v-deep .u-close--top-right{
top:0 !important;
right:20rpx !important;
}
.yaoqbtn {
color: #fff;
position: absolute;
bottom: 0;
text-align: center;
line-height: 60rpx;
left: 60rpx;
width: 200rpx;
height: 60rpx;
background: linear-gradient(90deg, #85C8AE 0%, #03AD6B 59%);
border-radius: 36rpx;
}
.yaoqbtn2 {
color: #fff;
position: absolute;
text-align: center;
line-height: 60rpx;
bottom: 0;
right: 60rpx;
width: 200rpx;
height: 60rpx;
background: linear-gradient(90deg, #64B0F9 0%, #436BF6 59%);
border-radius: 36rpx;
}
.yaoqing {
height: 1200rpx;
}
.PurchasePage {
position: fixed;
bottom: 0;
height: 960rpx;
width: 100%;
background: #FFFFFF;
border-radius: 30rpx 30rpx 0px 0px;
font-size: 36rpx;
padding-bottom: 20rpx;
z-index: 10;
.bodys {
background-color: #FFFFFF;
width: 96%;
margin: 10rpx auto 0;
border-radius: 20rpx;
padding: 15rpx 0 20rpx;
position: relative;
.addressinfo {
font-size: 32rpx;
line-height: 65rpx;
margin-left: 90rpx;
image {
width: 40rpx;
height: 50rpx;
position: absolute;
top: 50%;
left: 20rpx;
transform: translateY(-50%);
}
.address {
padding-top: 10rpx;
width: 92%;
font-size: 30rpx;
word-break: break-all;
line-height: 45rpx;
}
.namephone {
width: 70%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.picture2 {
position: absolute;
top: 50%;
right: 20rpx;
transform: translateY(-50%);
image {
width: 18rpx;
height: 18rpx;
color: #FFFFFF;
margin-left: 20rpx;
}
}
}
}
.topcontent {
width: 96%;
margin: 0 auto;
padding-bottom: 15rpx;
position: relative;
.goodsStock {
font-size: 24rpx;
position: absolute;
top: 75%;
right: 10rpx;
}
.prices {
position: absolute;
top: 70%;
left: 35%;
.price {
color: #D43953;
}
}
.title {
font-size: 36rpx;
position: absolute;
top: 3%;
left: 35%;
font-weight: 600;
width: 58%;
// height: 85rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
word-break: break-all;
}
.image {
width: 200rpx;
height: 200rpx;
margin: 15rpx 0 0 0;
image {
width: 201rpx;
height: 201rpx;
margin: 7rpx 0 0 7rpx;
}
}
}
.buy {
width: 60%;
height: 71rpx;
background: #4C7BC9;
color: #FFFFFF;
text-align: center;
line-height: 71rpx;
border-radius: 26rpx;
position: absolute;
bottom: 30rpx;
left: 20%;
}
.centercontent {
font-size: 32rpx;
background-color: #FFFFFF;
margin-top: 10rpx;
padding-top: 20rpx;
border-radius: 20rpx;
.header {
margin-bottom: 20rpx;
margin-left: 17rpx;
}
.productmodel {
border: 4rpx solid #FFFFFF;
}
.Productmodel {
background: #ECF1FA;
border: 4rpx solid #4C7BC9;
color: #4C7BC9;
}
.productmodel,
.Productmodel {
background-color: #F6F6F6;
height: 300rpx;
text-align: center;
width: 30%;
font-size: 24rpx;
border-radius: 10rpx;
margin: 5rpx 1.5% 10rpx;
padding: 0 0 10rpx;
view {
background-color: #F6F6F6;
margin: 10rpx auto;
width: 98%;
// height: 90rpx;
border-radius: 10rpx;
font-size: 24rpx;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
image {
border-radius: 10rpx;
width: 100%;
height: 200rpx;
}
}
}
}
.mask {
position: fixed;
bottom: 0;
height: 600rpx;
width: 100%;
background-color: #fff;
z-index: 10;
.maskitems {
color: #fff;
width: 90%;
margin: 60rpx auto 0;
.item {
background: #557BC2;
width: 100%;
margin: 0 auto 20rpx;
height: 150rpx;
position: relative;
font-size: 26rpx;
.btn {
text-align: center;
width: 120rpx;
height: 50rpx;
background: #FFFFFF;
border-radius: 22rpx;
position: absolute;
right: 30rpx;
top: 58rpx;
line-height: 50rpx;
font-size: 28rpx;
color: #557BC2;
}
.text {
position: absolute;
left: 150rpx;
top: 90rpx;
}
.titletext {
position: absolute;
left: 150rpx;
top: 48rpx;
}
image {
margin: 49rpx 0 0 43rpx;
width: 66rpx;
height: 66rpx;
}
}
}
.title {
padding-top: 10rpx;
font-size: 38rpx;
font-weight: 600;
text-align: center;
width: 100%;
}
}
.items {
margin-top: 30rpx;
.item {
width: 92%;
margin: 0 auto 12rpx;
background-color: #FFFFFF;
height: 220rpx;
position: relative;
.text {
font-size: 24rpx;
position: absolute;
left: 220rpx;
top: 90rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis
}
.btn {
position: absolute;
right: 40rpx;
top: 140rpx;
width: 150rpx;
height: 50rpx;
background: #557BC2;
border-radius: 22rpx;
color: #fff;
text-align: center;
font-size: 28rpx;
color: #FFFFFF;
line-height: 50rpx;
}
.jifen {
position: absolute;
left: 220rpx;
top: 140rpx;
font-size: 26rpx;
color: #666666;
}
.title {
width: 460rpx;
font-size: 34rpx;
font-weight: 600;
position: absolute;
left: 220rpx;
top: 25rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis
}
image {
margin: 15rpx 0 0 15rpx;
width: 180rpx;
height: 180rpx;
}
}
}
.titles {
margin: 38rpx 0 0 31rpx;
font-size: 30rpx;
}
.vacancies {
width: 92%;
height: 330rpx;
margin: 0 auto;
position: relative;
color: #fff;
.bottombutton {
position: absolute;
top: 230rpx;
left: 50%;
font-size: 32rpx;
color: #557BC2;
line-height: 72rpx;
text-align: center;
transform: translateX(-50%);
width: 440rpx;
height: 72rpx;
background: #FFFFFF;
border-radius: 36rpx;
}
.centertext {
position: absolute;
top: 160rpx;
width: 100%;
text-align: center;
font-size: 28rpx;
opacity: 0.8;
}
.title {
position: absolute;
left: 50%;
font-size: 70rpx;
top: 90rpx;
transform: translateX(-50%);
}
.righttext {
position: absolute;
top: 32rpx;
right: 31rpx;
font-size: 24rpx;
line-height: 28rpx;
width: 130rpx;
height: 28rpx;
image {
position: absolute;
left: 0;
width: 28rpx;
height: 28rpx;
}
view {
opacity: 0.6;
position: absolute;
right: 0;
}
}
.lefttext {
position: absolute;
top: 32rpx;
left: 33rpx;
font-size: 30rpx;
line-height: 33rpx;
}
image {
width: 100%;
height: 100%;
}
}
}

View File

@ -0,0 +1,657 @@
<template>
<view class="app">
<view class="vacancies">
<image src="../../static/pagesB/jifenbeijing.png" mode=""></image>
<view class="lefttext">
健康豆余额
</view>
<view class="righttext">
<!-- <image src="../../static/jfgz.png" mode=""></image>
<view class="">
积分规则
</view> -->
</view>
<view class="title">
{{list.integral}}
</view>
<view class="centertext">
<!-- 20积分将于2022.01.01过期 -->
</view>
<view class="bottombutton" @tap='gainshow=true'>
获取健康豆
</view>
</view>
<view class="titles">
健康豆兑换
</view>
<view class="items" v-if='goodslist'>
<view class="item" v-for="(item,index) in goodslist" :key="index">
<image :src="item.attributePitureUrl" mode=""></image>
<view class="title">
{{item.goodsName}}
</view>
<view class="text">
{{item.integralExchangeCount}}{{item.goodsUnit}}
</view>
<view class="jifen">
需使用
<span style='padding: 0 5rpx;'> {{item.integralExchangeSill}}</span>
健康豆兑换
</view>
<view class="btn" @tap='buyshowtrue(item)'>
立即兑换
</view>
</view>
</view>
<view class="noorder" v-else>
<u-empty mode="list" icon-size='220' text='暂无可兑换商品'></u-empty>
</view>
<u-mask :show="gainshow" @click="gainshow = false">
<view class="mask" @click.stop="">
<image class="close" src="../../static/pagesB/gb.png" mode="" @tap='gainshow=false'></image>
</image>
<view class="title">
获取方式
</view>
<view class="maskitems">
<view class="item">
<image src="../../static/pagesB/qiandao.png" mode=""></image>
<view class="titletext">
累计签到
<span style='padding: 0 5rpx;' v-if="list.totalSignInDays"> {{list.totalSignInDays}}</span>
<span style='padding: 0 5rpx;' v-else>0</span>
(当前签到
<span style='padding: 0 5rpx;' v-if="list.patientSignInCount">
{{list.patientSignInCount}}</span>
<span style='padding: 0 5rpx;' v-else>0</span>
)
</view>
<view class="text">
<span style='padding: 0 5rpx;' v-if="list.signInCount"> {{list.signInCount}}</span>
<span style='padding: 0 5rpx;' v-else>0</span>健康豆
</view>
<view class="btn" @tap='signIninfo' v-if='list.todaySignInCount==0&&list.totalSignInDays>0'>
签到
</view>
<view class="btn" v-if='list.todaySignInCount==1'>
已签到
</view>
</view>
<view class="item" style="background-color: #F44B2F;">
<image src="../../static/pagesB/yaoqing.png" mode=""></image>
<view class="titletext">
每邀请
<span style='padding: 0 5rpx;'> 1</span>
位好友
</view>
<view class="text">
<span style='padding: 0 5rpx;' v-if="list.inviteFriends"> {{list.inviteFriends}}</span>
<span style='padding: 0 5rpx;' v-else>0</span>
健康豆
</view>
<view class="btn" style="color: #F44B2F;" @tap='yaoqingshowtrue' v-if='list.inviteFriends>0'>
去完成
</view>
</view>
</view>
</view>
</u-mask>
<u-mask :show="buyshow" @click="buyshow = false">
<view class="PurchasePage" @click.stop=''>
<image class="close" src="../../static/pagesB/gb.png" mode="" @tap='buyshow=false'></image>
</image>
<view class="topcontent" style="width: 96%;">
<view class="image">
<image :src="goodsitem.goodsPictureUrl" mode=""></image>
</view>
<view class="title" v-if="goodsitem.goodsName">
{{goodsitem.goodsName||'暂无'}}
</view>
<view class="prices">
<span class="price">
{{goodsitem.integralExchangeSill}}健康豆
</span>
</view>
<view class="goodsStock">
库存数量:{{goodsitem.goodsStock}}
</view>
</view>
<view class="bodys" @tap='upaddress()'>
<view class="addressinfo">
<image src="../../static/pagesB/locatinsmall.png" mode=""></image>
<span v-if="loginFlag">
<view class="namephone" v-if='userid'>
{{updata.receiver}},{{updata.phone}}
</view>
<view class="address" v-if='userid'>
{{updata.receiveAddress}}
</view>
</span>
<view class="namephone" v-else>
前往完善个人信息
</view>
<view class="picture2">
<u-icon name="arrow-right" color="black" size="28"></u-icon>
</view>
</view>
</view>
<view class="centercontent topcontent">
<view class="header">
商品规格
</view>
<view style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
<view class="Productmodel productmodel">
<image :src="goodsitem.attributePitureUrl" mode=""></image>
<view class="">
{{goodsitem.integralExchangeCount}}{{goodsitem.goodsUnit}}
</view>
</view>
</view>
</view>
<view class="buy" @tap="upbuy">
立即兑换
</view>
</view>
</u-mask>
<u-popup v-model="yaoqingshow" mode="center" :closeable='true' :close='yaoqingshowfalse'>
<view class="yaoqing">
<r-canvas ref="rCanvas" v-if="yaoqingshow"></r-canvas>
</view>
<view class="yaoqbtn" @tap='draw'>
保存到相册
</view>
<view class="yaoqbtn2" @tap='fenx'>
分享给好友
</view>
</u-popup>
<u-mask :show="usershow" class='masks'>
<view class="information">
<image src="../../static/information.png" mode=""></image>
<view class="title">
请完善个人信息
</view>
<view class="cancel" @tap='usershow=false'>
取消
</view>
<view class="determine" @tap='goinformation'>
去完善
</view>
</view>
</u-mask>
<u-toast ref="uToast" />
</view>
</template>
<script>
// import {
// signIn,
// selectPatientSignIn,
// selectExchangeGoods,
// integralGoodsOrder
// } from '@/api/integral/index.js'
// import {
// inviteFriends
// } from '@/api/Personal/Personal.js';
// import {
// goodPatientInfo
// } from '@/api/modifyAddress/modifyAddress.js';
// import {
// AppIdentification
// } from '@/api/AppIdentification/index.js'
import baseurl from '../../api/baseurl';
import rCanvas from "@/components/r-canvas/r-canvas.vue"
export default {
components: {
rCanvas
},
data() {
return {
timer: null,
baseurl: '',
patientId: null,
integral: 0,
usershow: false, //go
gainshow: false, //
buyshow: false, //
yaoqingshow: false,
yaoqingimg: null,
yapqingbeijingimg: null,
list: {
integral: 0
},
inviteimg: null, //
pageNum: 1,
pageSize: 10,
goodstotal: 0,
goodslist: null,
goodsitem: null,
userid: null,
updata: {
"orderChannel": 'WECHAT_APPLET',
"originalTotalPrice": null,
"integralExchangeSill": null,
"integralExchangeCount": null,
"orderType": "INTEGRAL_EXCHANGE",
"buySource": "SHOPPING_MALL",
"integralDeductionCount": null,
"attributeDetailsId": null,
"discountPrice": null,
"giveIntegral": null,
"goodsAttributeContent": null,
"goodsAttributeDetailsId": null,
"goodsAttributeId": null,
"goodsAttributeName": null,
"goodsCount": null,
"goodsName": null,
"goodsPrice": null,
"goodsStock": null,
"nurseStationId": null,
"patientId": null,
"phone": "18963146613",
"receiveAddress": null,
"receiver": null,
},
loginFlag: false,
};
},
onLoad(options) {},
// onShow() {
// this.baseurl = baseurl
// this.pageNum = 1
// this.selectExchangeGoodsinfo();
// this.baseurl = baseurl
// this.yapqingbeijingimg = baseurl + '/profile/appletPicture/inviteFriendsTwo.png'
// var that = this
// const value = uni.getStorageSync('patientId');
// if (value) {
// that.patientId = value
// that.updata.patientId = value
// that.selectPatientSignInifo();
// that.user();
// AppIdentification(value).then(res => {
// if (res.code == 200) {
// if (res.data.loginFlag) {
// that.loginFlag = true
// }
// }
// })
// goodPatientInfo(value).then(res => {
// if (res.code == 200) {
// if (res.data.length > 0) {
// var user = res.data.filter(e => e.id == that.userid)
// if (user.length >= 1) {
// that.updata.receiver = user[0].receiveName
// that.updata.receiveAddress = user[0].areaName + user[0].receiveAddress
// that.updata.phone = user[0].receivePhone
// that.userid = user[0].id
// } else {
// that.updata.receiver = res.data[0].receiveName
// that.updata.receiveAddress = res.data[0].areaName + res.data[0].receiveAddress
// that.updata.phone = res.data[0].receivePhone
// that.userid = res.data[0].id
// }
// }
// }
// })
// } else {
// that.$refs.uToast.show({
// title: ',',
// type: 'error',
// duration: '2000',
// })
// }
// let useritem = null
// uni.$on('updata', function(data) {
// if (data.useritem) {
// useritem = JSON.parse(data.useritem)
// that.updata.receiver = useritem.receiveName
// that.updata.phone = useritem.receivePhone
// that.updata.receiveAddress = useritem.areaName + useritem.receiveAddress
// that.userid = useritem.id
// }
// uni.$off('updata')
// })
// },
methods: {
yaoqingshowtrue() {
this.yaoqingshow = true
this.$nextTick(async () => {
await inviteFriends(this.patientId).then(res => {
this.inviteimg = res.msg
})
uni.showLoading({
title: '加载中'
});
//
await this.$refs.rCanvas.init({
canvas_id: "rCanvas"
})
//
await this.$refs.rCanvas.drawImage({
url: this.yapqingbeijingimg,
x: 0,
y: 0,
w: 300,
h: 530
}).catch(err_msg => {
uni.showToast({
title: err_msg,
icon: "none"
})
})
await this.$refs.rCanvas.drawImage({
url: baseurl + this.inviteimg,
x: 85,
y: 340,
w: 130,
h: 130
}).catch(err_msg => {
uni.showToast({
title: err_msg,
icon: "none"
})
})
//
await this.$refs.rCanvas.drawText({
text: "智慧康养泉城,医护关怀到家",
x: 150,
y: 300,
font_color: "#444444",
font_size: 12,
font_weight: 600,
text_align: 'center'
}).catch(err_msg => {
uni.showToast({
title: err_msg,
icon: "none"
})
})
await this.$refs.rCanvas.drawText({
text: "超多福利,快来体验吧!",
x: 150,
y: 320,
font_color: "#444444",
font_size: 12,
font_weight: 600,
text_align: 'center'
}).catch(err_msg => {
uni.showToast({
title: err_msg,
icon: "none"
})
})
await this.$refs.rCanvas.drawText({
text: "泉医到家小程序",
x: 150,
y: 500,
font_color: "#444444",
font_size: 10,
text_align: 'center'
}).catch(err_msg => {
uni.showToast({
title: err_msg,
icon: "none"
})
})
await this.$refs.rCanvas.drawText({
text: "(长按识别二维码开启健康之旅)",
x: 150,
y: 515,
font_color: "#444444",
font_size: 7,
text_align: 'center'
}).catch(err_msg => {
uni.showToast({
title: err_msg,
icon: "none"
})
})
//
await this.$refs.rCanvas.draw((res) => {
this.yaoqingimg = res.tempFilePath
uni.hideLoading();
//res.tempFilePathbase64
//
// this.$refs.rCanvas.saveImage(res.tempFilePath)
})
})
},
//
draw() {
//
this.$refs.rCanvas.saveImage(this.yaoqingimg).then(res => {
uni.showToast({
title: '保存成功',
duration: 2000
});
}).catch(err => {
uni.showToast({
icon: 'error',
title: '保存失败',
duration: 2000
});
})
},
//
fenx() {
wx.showShareImageMenu({
path: this.yaoqingimg,
})
},
yaoqingshowfalse() {
this.yapqingshow = false;
this.$nextTick(async () => {
await this.$refs.rCanvas.clearCanvas((res) => {})
await this.$refs.rCanvas.setCanvasWidth(0)
await this.$refs.rCanvas.setCanvasHeight(0)
})
},
//
upbuy() {
var that = this
this.updata.goodsCount = this.updata.integralExchangeCount
const value = uni.getStorageSync('patientId');
const value2 = uni.getStorageSync('openid');
if (value && value2) {
AppIdentification(value).then(res => {
if (res.code == 200) {
if (res.data.loginFlag) {
integralGoodsOrder(that.updata).then(res => {
if (res.code == 200) {
that.selectPatientSignInifo();
that.$refs.uToast.show({
title: '兑换商品成功',
type: 'success',
url: `/pages/orderDetails/orderDetails?goodsOrderId=${res.data.id}`
})
that.buyshow = false
} else {
that.$refs.uToast.show({
title: res.msg,
type: 'error'
})
}
})
} else {
that.usershow = true
}
} else {
that.$refs.uToast.show({
title: '请先登录',
type: 'error',
duration: '2000',
url: '/pages/login/login'
})
}
})
} else {
that.$refs.uToast.show({
title: '请先登录',
type: 'error',
duration: '2000',
url: '/pages/login/login'
})
}
},
//
upaddress() {
if (this.updata.receiver) {
uni.navigateTo({
url: `/pages/modifyAddress/modifyAddress?updata=${JSON.stringify(this.updata)}`
})
} else {
const value = uni.getStorageSync('openid');
const value2 = uni.getStorageSync('patientId');
if (value && value2) {
uni.navigateTo({
url: '/pages/information/information'
})
} else {
this.$refs.uToast.show({
title: '未登录,请先登录',
type: 'error',
url: '/pages/login/login'
})
}
}
},
///
buyshowtrue(item) {
this.buyshow = true
this.goodsitem = item
this.updata.nurseStationId = item.nurseStationId
this.updata.goodsAttributeName = this.goodsitem.attributeDetailsName
this.updata.goodsAttributeId = this.goodsitem.goodsAttributeId
this.updata.goodsAttributeDetailsId = this.goodsitem.attributeDetailsId
this.updata.integralExchangeSill = this.goodsitem.integralExchangeSill
this.updata.integralExchangeCount = this.goodsitem.integralExchangeCount
this.updata.originalTotalPrice = 0
this.updata.goodsStock = this.goodsitem.goodsStock
this.updata.goodsName = this.goodsitem.goodsName
this.updata.goodsPrice = this.goodsitem.goodsPrice
this.updata.goodsCount = 1
},
//
selectExchangeGoodsinfo() {
this.pageNum = 1
selectExchangeGoods(this.pageNum, this.pageSize).then(res => {
if (res.code == 200) {
res.rows.forEach(e => {
e.goodsPictureUrl = baseurl + e.goodsPictureUrl
e.attributePitureUrl = baseurl + e.attributePitureUrl
})
if (res.rows.length > 0) {
this.goodslist = res.rows
this.goodstotal = res.total
}
} else if (res.code == 9999) {
this.$refs.uToast.show({
title: '未登录,请先登录',
type: 'error',
})
}
})
},
//
selectPatientSignInifo() {
selectPatientSignIn(this.patientId).then(res => {
this.list = res.data
})
},
//
signIninfo() {
var that = this
const value = uni.getStorageSync('patientId');
const value2 = uni.getStorageSync('openid');
if (value && value2) {
AppIdentification(value).then(res => {
if (res.code == 200) {
if (res.data.loginFlag) {
signIn(value).then(res => {
if (res.code == 200) {
that.selectPatientSignInifo();
that.$refs.uToast.show({
title: '今日签到成功',
type: 'success',
duration: '1000',
})
} else {
that.$refs.uToast.show({
title: '签到失败',
type: 'error',
duration: '1000',
})
}
})
} else {
that.usershow = true
}
} else {
that.$refs.uToast.show({
title: '请先登录',
type: 'error',
duration: '2000',
url: '/pages/login/login'
})
}
})
} else {
that.$refs.uToast.show({
title: '请先登录',
type: 'error',
duration: '2000',
url: '/pages/login/login'
})
}
},
//
user() {
goodPatientInfo(this.patientId).then(res => {
if (res.data.length > 0) {
var list = res.data.filter(e => e.defaultAddressFlag == 1)
if (list.length >= 1) {
this.updata.receiver = list[0].receiveName
this.updata.receiveAddress = list[0].areaName + list[0].receiveAddress
this.updata.phone = list[0].receivePhone
this.userid = list[0].id
} else {
this.updata.receiver = res.data[0].receiveName
this.updata.receiveAddress = res.data[0].areaName + res.data[0].receiveAddress
this.updata.phone = res.data[0].receivePhone
this.userid = res.data[0].id
}
}
})
},
//
goinformation() {
this.usershow = false
uni.navigateTo({
url: '/pages/information/information'
})
},
},
onReachBottom() { //
if (this.goodslist.length >= this.goodstotal) {} else {
this.pageNum++;
selectExchangeGoods(this.pageNum, this.pageSize).then(res => {
res.rows.forEach(e => {
e.goodsPictureUrl = baseurl + e.goodsPictureUrl
this.goodslist.push(e)
})
})
}
},
onPullDownRefresh() { //
this.pageNum = 1;
this.selectExchangeGoodsinfo();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
}
</script>
<style lang="scss">
@import "./healthybeans.scss";
</style>

BIN
static/information.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
static/pagesB/gb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

BIN
static/pagesB/qiandao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
static/pagesB/yaoqing.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB