初次提交

This commit is contained in:
lym
2026-03-09 13:54:17 +08:00
commit 8e25ad708b
516 changed files with 41896 additions and 0 deletions

310
pages/mybusiness/index.js Normal file
View File

@@ -0,0 +1,310 @@
var app = getApp()
var that=null
var sopenFrame=null
var mCanvas
Page( {
data: {
loadingHidden:false,
ewmpic:"",
width:300,
height:400,
sjylmoney: 0,
smzemoney: 0,
zsymoney: 0,
jrmoney:0,
zrmoney:0,
IFDefault:false,
savetitle:"保存商家收款码到相册"
},
onLoad: function() {
that = this
that.rdata()
}, // 下拉刷新
onPullDownRefresh: function () {
that.rdata()
},rdata: function() {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
var userInfodata = wx.getStorageSync("userInfo")
var userInfo = JSON.parse(userInfodata)
wx.request({
url: app.globalData.apiurl + "/xapiajax.ashx",
data: {
action:"getmybusinessdata",
userId:(!userId?"":userId),
LoginId:(!LoginId?"":LoginId)
},
method:"GET",
dataType:"json",
success (res) {
if(res.data.status==1){
that.setData({
sjylmoney: res.data.sjylmoney,
smzemoney: res.data.smzemoney,
zsymoney: res.data.zsymoney,
jrmoney:res.data.jrmoney,
zrmoney:res.data.zrmoney,
IFDefault:(res.data.userInfo.Paypush==1?true:false),
width:300,
height:400,
loadingHidden:true
})
wx.createSelectorQuery().select('#myCanvas')
.fields({ node: true, size: true })
.exec((res0) => {
let textCanvas = res0[0].node; // 重点1
mCanvas=textCanvas
let textCtx = textCanvas.getContext('2d'); // 重点2
const dpr = wx.getSystemInfoSync().pixelRatio
var w=res0[0].width
var h=res0[0].height
textCanvas.width = w * dpr
textCanvas.height = h * dpr
textCtx.scale(dpr, dpr)
textCtx.clearRect(0,0,textCanvas.width,textCanvas.height)
textCtx.beginPath();
//绘制背景
textCtx.fillStyle = '#fff'
textCtx.clearRect(0,0, textCanvas.width, textCanvas.height)
textCtx.fillRect(0, 0, textCanvas.width, textCanvas.height)
const bg = textCanvas.createImage();
bg.src = '../../images/skm.png';
bg.onload = () => {
textCtx.drawImage(bg, 0, 0, w, h)
let text1 = res.data.sjname
let len=((w-text1.length*20)/2)
textCtx.fillStyle = "#000";
textCtx.font = "22px Arial";
textCtx.fontWeight = 'bold'
//textCtx.textAlign = 'center'
that.getWarpText(textCtx, text1, len, 100, w, 52, 1)
if(res.data.ewmpic!=""){
const bg0 = textCanvas.createImage();
bg0.src = res.data.ewmpic;
bg0.onload = () => {
textCtx.drawImage(bg0, ((w-145)/2), 130, 145, 145)
}
}
}
})
}else{
}
}
})
},onxz: function(e) {
that.setData({
savetitle:"保存中,请稍候..."
})
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
wx.canvasToTempFilePath({
canvasId: "myCanvas",
destWidth: 520,
destHeight: 720,
canvas: mCanvas,
success: function(res0) {
// 获取图片路径
const tempFilePath = res0.tempFilePath;
wx.saveImageToPhotosAlbum({
filePath: tempFilePath,
success(res) {
console.log(res);
wx.showModal({
title: '图片保存成功',
content: '图片成功保存到相册了,去发圈噻~',
showCancel: false,
confirmText: '好哒',
confirmColor: '#72B9C3',
success: function (res0) {
if (res0.confirm) {
}
that.setData({
QRcodeHidden: true,
savetitle:"保存商家收款码到相册"
})
}
})
}
})
},
fail: function(err) {
wx.showToast({
title: err,
icon: "none",
duration: 10000
})
}
})
},onsmlog: function(e) {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
var userInfodata = wx.getStorageSync("userInfo")
if(userId&&LoginId&&userInfodata){
var t = e.currentTarget.dataset.id
wx.navigateTo({
url: "../mybusiness_smlog/index?t=" + t
})
}else{
wx.navigateTo({
url: "../login/index"
})
}
},onzzlog:function(e) {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
if(!userId||!LoginId){
wx.navigateTo({
url: "../login/index"
})
}else{
wx.navigateTo({
url: "../zzjf_log/index"
})
}
},changeisDefault:function(e) {
var t = (e.detail.value==true?1:0)
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
wx.request({
url: app.globalData.apiurl + "/xapiajax.ashx",
data: {
action:"updatePaypush",
userId:(!userId?"":userId),
LoginId:(!LoginId?"":LoginId),
t:t
},
method:"POST",
dataType:"json",
header: {
"content-type": "application/x-www-form-urlencoded" // 默认值
},
success (res) {
if(res.data.status==1){
wx.showToast({
title: res.data.msg,
icon: "success",
duration: 3000
})
wx.setStorageSync('userInfo', JSON.stringify(res.data.userInfo))
that.rdata()
}else{
wx.showToast({
title: res.data.msg,
icon: "none",
duration: 3000
})
}
}
})
},onsjzl:function(e) {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
if(!userId||!LoginId){
wx.navigateTo({
url: "../login/index"
})
}else{
wx.navigateTo({
url: "../mybusiness_info/index"
})
}
},onsylog: function(e) {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
var userInfodata = wx.getStorageSync("userInfo")
if(userId&&LoginId&&userInfodata){
wx.navigateTo({
url: "../zzjf_sylog/index?t=5"
})
}else{
wx.navigateTo({
url: "../login/index"
})
}
},getWarpTextMulti:function(canvas, arrText, y, gap = 10) {
for (let index = 0; index < arrText.length; index++) {
const text = arrText[index];
let lineArr = getWarpText(canvas, text, MARGIN_LEFT, y, MAX_WIDTH, LINE_HEIGHT)
y += LINE_HEIGHT * lineArr.length + gap
}
},getWarpText:function(canvas, text, x, y, maxWidth, lineHeight, maxLine) {
// 对入参的类型进行检测
if (typeof text != 'string' || typeof x != 'number' || typeof y != 'number' || typeof lineHeight != 'number') {
throw new Error("参数传入出错")
}
//如果最大宽度未定义 默认为canvas宽度
if (typeof maxWidth == 'undefined') {
maxWidth = (canvas && canvas.width);
}
if (typeof lineHeight == 'undefined') {
lineHeight = (canvas.canvas && parseInt(window.getComputedStyle(canvas.canvas).lineHeight)) ||
parseInt(window.getComputedStyle(document.body).lineHeight)
}
let arrText = text.split('');
let line = '';
let lines = [];
let lastLine = ""
let ellipsis = canvas.measureText("...");
let ellipsisWidth = ellipsis.width;
for (let n = 0; n < arrText.length; n++) {
//每个循环累加字符
let testLine = line + arrText[n];
//检测累加字符 获取累加字符的高度和宽度
let metrics = canvas.measureText(testLine);
let testWidth = metrics.width;
let lineWidth = canvas.measureText(line).width;
// 如果当前添加行是最后一行 则替换最后一个字符为"..." 判断长度是否需要删去最后一个字符
if (maxLine && maxLine - 1 === lines.length && ((lineWidth + ellipsisWidth) > maxWidth)) {
line = line.slice(0, line.length - 1) + "...";
testWidth = lineWidth + ellipsisWidth;
}
//如果累加字符的宽度大于定义的绘制文本最大宽度 则绘制累加字符的文本 并且设置换行间距再次进行绘制
if (testWidth > maxWidth && n > 0) {
lastLine = line;
lines.push({
text: line,
x: x,
y: y
})
if (maxLine && maxLine <= lines.length) {
break
}
line = arrText[n];
y += lineHeight;
} else {
line = testLine;
}
}
if (lastLine !== line) {
lines.push({
text: line,
x: x,
y: y
})
}
for (let i = 0; i < lines.length; i++) {
const item = lines[i];
canvas.fillText(item.text, item.x, item.y);
}
return lines;
}
})

View File

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "联盟商家管理"
}

View File

@@ -0,0 +1,64 @@
<view class="container">
<view class="emx_box">
<view>
<canvas type="2d" canvas-id="myCanvas" id="myCanvas" style="width: 100vw; height: 130vw;"></canvas>
</view>
<view class="button_box">
<view class="button_box_item" style="width:100%">
<view class="mybtn" bindtap="onxz">{{savetitle}}</view>
</view>
</view>
</view>
<view class="emx_button_box">
<view class="zzjfmx_box">
<view class="Paypush_box">
<text>开启/关闭收款自动播报:</text>
<switch checked='{{IFDefault}}' color="#00B050" bindchange="changeisDefault"></switch>
</view>
<view class="gxzmx_box">
<view bindtap="onsmlog" data-id="0" class="alink">
<text>扫码总额</text>
<text class="je">{{smzemoney}}</text>
</view>
<view bindtap="onsmlog" data-id="1" class="alink">
<text>今日金额</text>
<text class="je">{{jrmoney}}</text>
</view>
<view bindtap="onsmlog" data-id="2" class="alink">
<text>昨日金额</text>
<text class="je">{{zrmoney}}</text>
</view>
</view>
<view class="gxzmx_box">
<view>
<text>商家让利</text>
<text class="je">{{sjylmoney}}%</text>
</view>
<view bindtap="onzzlog" class="alink">
<text>增值积分</text>
<text class="je">{{zsymoney}}</text>
</view>
<view bindtap="onsjzl" class="alink">
<text>查看商家资料</text>
</view>
</view>
</view>
</view>
</view>
<loading hidden="{{loadingHidden}}">
加载中...
</loading>

168
pages/mybusiness/index.wxss Normal file
View File

@@ -0,0 +1,168 @@
page{
background: #ccc;
}
.container {
position: relative;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-flex-flow: column;
width: 100%;
height: 100%;
padding: 0;
font-size: 14px;
color: #000;
}
.footer{
position: fixed;
z-index: 10000;
bottom:0;
left:0;
width: 100%;
text-align: center;
padding: 0;
}
.footer button{width:100%;height:2.5em; line-height: 2.5em; background:linear-gradient(to right,#00B050,#00B050); color:#fff;border-radius:0;}
.emx_box{
display: flex;flex-direction: column;width:100%; box-sizing: border-box; border-radius:0.5em;
}
.emx_box_to{
width:100%;
background-color: #fff;
}
.Canvas_box_to{
display: none;
}
.Canvas_box_to canvas{
width:100%;
}
.emx_box_to image{
width:100%;
}
.emx_button_box{
display: flex;flex-direction: column;width:100%; padding: 0.8em; box-sizing: border-box; border-radius:0.5em;
}
.button_box{
display: flex;
flex-direction: row;
margin: 0;
padding:0;
padding-right: 0.8em;
width: 100%;
box-sizing: border-box;
align-items: center;
justify-content: center;
background-color: #fff;
border-radius:0.5em;
}
.button_box form{
width: 100%;
}
.button_box .button_box_to{
display: flex;
flex-direction: row;
width: 100%;
}
.button_box .button_box_item{
display: flex;
flex-direction: column;
flex-grow: 1;
width:50%;
height:2.5em;
margin: 0;
padding: 0.8em;
padding-right: 0;
}
.button_box .button_box_item .mybtn{
width: 100%;
height: 100%;
border-radius: 0.4em;
background-color: #00B050;
color:#fff;
line-height: 2.5em;
text-align: center;
font-size: 1em;
}
.gxzmx_box {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
background-color: #fff;
margin: 0;
padding: 0em;
text-align: center;
border-radius: 0.7em 0.7em 0 0;
border-bottom: 1px solid #f1f1f1;
box-sizing: border-box;
}
.gxzmx_box view {
display: flex;
flex-direction: column;
width: 50%;
align-items: center;
justify-items: center;
padding-top: 1.2em;
padding-bottom: 1.2em;
box-sizing: border-box;
}
.gxzmx_box view image {
display: block;
width:3em;
height:3em;
}
.gxzmx_box view text {
display: block;
color: #000;
font-size: 1em;
}
.gxzmx_box view text.je {
color: #000;
font-weight: 800;
}
.gxzmx_box view.alink text{
color:#00B050;
}
.Paypush_box{
display: flex;
flex-direction:row;
align-items: center;
width: 100%;
padding: 0.8em;
border-bottom:1px solid #f1f1f1;
box-sizing: border-box;
}
.zzjfmx_box {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
background-color: #fff;
margin: 0;
margin-top: 0.8em;
padding: 0em;
text-align: center;
border-radius: 0.5em;
overflow: hidden;
box-sizing: border-box;
}
.zzjfmx_box .title {
width: 100%;
height: 2.5em;
line-height: 2.5em;
font-size: 1em;
text-align: left;
border-bottom: 1px solid #f1f1f1;
padding: 0 0.8em;
box-sizing: border-box;
font-size: 1em;
font-weight: 900;
}
.nodata{padding-top:1em; text-align: center; line-height: 1.5em; color:#939393;}
.nodata image {
width: 80px;
height: 80px;
}