增加消息订阅
This commit is contained in:
parent
a4b8511822
commit
4bb4328c2f
|
|
@ -0,0 +1,17 @@
|
|||
import http from './http.js'
|
||||
const request=http.request
|
||||
|
||||
|
||||
/**
|
||||
* 获取订阅二维码
|
||||
* @returns
|
||||
*/
|
||||
export function getSubQrCode(params) {
|
||||
return request({
|
||||
url: `/api/msg/subQrCode`,
|
||||
method: 'get',
|
||||
params: {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
<template>
|
||||
<view class="page-wrapper">
|
||||
<view class="content">
|
||||
<view class="title">消息订阅码</view>
|
||||
<view ref="qrcode" class="qrcode">
|
||||
<image :src="vdata.QrcodeUrl" style="width: 100%;height: 100%;" mode="scaleToFill" />
|
||||
</view>
|
||||
<view class="bom">
|
||||
<view @click="saveImage">保存订阅码</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import qrCode from '@/commons/utils/qrCode.js'
|
||||
import { getSubQrCode } from '@/http/yskApi/pageNotification.js'
|
||||
import { saveHeadImgFile } from '@/commons/utils/saveImg.js'
|
||||
const vdata = reactive({
|
||||
size: 20,
|
||||
QrcodeUrl: "",
|
||||
|
||||
});
|
||||
|
||||
onLoad((options) => {
|
||||
|
||||
})
|
||||
|
||||
|
||||
onShow(() => {
|
||||
getSubQrCode().then((res) => {
|
||||
vdata.QrcodeUrl = res;
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
const saveImage = () => {
|
||||
// #ifdef APP-PLUS
|
||||
saveQrcodeImg()
|
||||
uni.downloadFile({
|
||||
url: vdata.QrcodeUrl,
|
||||
success: (res) => {
|
||||
console.log(res)
|
||||
if (res.statusCode == 200) {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: res.tempFilePath,
|
||||
success: (r) => {
|
||||
infoBox.showSuccessToast('保存成功')
|
||||
uni.vibrateShort()
|
||||
},
|
||||
fail: (er) => {
|
||||
console.log(er)
|
||||
infoBox.showErrorToast('保存失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
infoBox.showErrorToast('保存失败')
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
//#ifdef MP-WEIXIN
|
||||
downloadQR()
|
||||
//#endif
|
||||
}
|
||||
//#ifdef MP-WEIXIN
|
||||
function downloadQR() {
|
||||
wx.getSetting({
|
||||
//获取权限
|
||||
success(res) {
|
||||
console.log(res)
|
||||
if (res.authSetting['scope.writePhotosAlbum']) {
|
||||
saveWxQrcodeImg(vdata.QrcodeUrl)
|
||||
} else {
|
||||
wx.authorize({
|
||||
scope: 'scope.writePhotosAlbum',
|
||||
success() {
|
||||
saveWxQrcodeImg(vdata.QrcodeUrl)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//#endif
|
||||
const saveQrcodeImg = () => {
|
||||
saveHeadImgFile(vdata.QrcodeUrl, 80)
|
||||
.then((success) => {
|
||||
infoBox.showSuccessToast('保存成功')
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
infoBox.showErrorToast('保存失败')
|
||||
})
|
||||
}
|
||||
|
||||
const saveWxQrcodeImg = (data) => {
|
||||
const fileManager = wx.getFileSystemManager()
|
||||
console.log( )
|
||||
const filePath = wx.env.USER_DATA_PATH + '/qrCode'+new Date().getTime()+'.png'
|
||||
//这块是定义图片的名称,可自定义其他
|
||||
fileManager.writeFile({
|
||||
filePath: filePath,
|
||||
data: data.slice(22),
|
||||
encoding: 'base64',
|
||||
success: (res) => {
|
||||
wx.saveImageToPhotosAlbum({
|
||||
filePath: filePath,
|
||||
success: function (res) {
|
||||
//保存成功
|
||||
infoBox.showSuccessToast('保存成功')
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log(err)
|
||||
//保存失败
|
||||
infoBox.showErrorToast('保存失败')
|
||||
},
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
infoBox.showErrorToast('保存失败')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.page-wrapper {
|
||||
min-height: calc(100vh - 90rpx);
|
||||
padding: 48rpx 52rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
.content{
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 40rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 64rpx 0;
|
||||
box-sizing: border-box;
|
||||
.title{
|
||||
font-weight: bold;
|
||||
font-size: 40rpx;
|
||||
color: #333333;
|
||||
}
|
||||
.qrcode{
|
||||
width: 416rpx;
|
||||
height: 416rpx;
|
||||
margin-top: 50rpx;
|
||||
border: 2rpx solid #333;
|
||||
padding: 15rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
::v-deep .u-qrcode,::v-deep .u-qrcode__content,::v-deep .u-qrcode__canvas{
|
||||
width: 100%!important;
|
||||
height: 100%!important;
|
||||
|
||||
}
|
||||
.bom{
|
||||
display: flex;
|
||||
margin-top: 110rpx;
|
||||
view{
|
||||
width: 218rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #318AFE;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
view:nth-child(1){
|
||||
color: #318AFE;
|
||||
border: 2rpx solid #318AFE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
11
pages.json
11
pages.json
|
|
@ -1076,6 +1076,17 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "pageNotification",
|
||||
"pages": [{
|
||||
"pageId": "PAGES_NOTIFICATION_INDEX",
|
||||
"path": "index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订阅通知"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
|
|
|||
|
|
@ -145,6 +145,11 @@
|
|||
icon: '/static/indexImg/icon-cashier.svg',
|
||||
pageUrl: 'PAGES_SHOP_SETUP',
|
||||
},
|
||||
{
|
||||
title: '订阅通知',
|
||||
icon: '/static/indexImg/icon-notification.svg',
|
||||
pageUrl: 'PAGES_NOTIFICATION_INDEX',
|
||||
},
|
||||
// // // {
|
||||
// // // title: '进销存',
|
||||
// // // icon: '/static/indexImg/icon-invoicing.svg',
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32"><defs><style>.a{fill:#80bcff;}.b{clip-path:url(#a);}.c{fill:#4c99fe;}.d{fill:#197dff;}</style><clipPath id="a"><rect class="a" width="32" height="32" transform="translate(329 962)"/></clipPath></defs><g class="b" transform="translate(-329 -962)"><g transform="translate(202.143 843.263)"><path class="c" d="M286.412,444.28m-9.08,0a9.08,9.08,0,1,0,9.08-9.08,9.08,9.08,0,0,0-9.08,9.08Z" transform="translate(-143.555 -303.517)"/><path class="d" d="M450.476,127.721A2.432,2.432,0,0,1,448,125.245v-3.3a2.476,2.476,0,1,1,4.953,0v3.3A2.483,2.483,0,0,1,450.476,127.721Z" transform="translate(-307.619)"/><path class="c" d="M213.791,210.185h-18.82A2.959,2.959,0,0,1,192,207.213v-7.1a12.381,12.381,0,1,1,24.763,0v7.1A2.959,2.959,0,0,1,213.791,210.185Z" transform="translate(-61.524 -65.625)"/><path class="d" d="M155.239,644.953H130.476a2.476,2.476,0,1,1,0-4.953h24.763a2.476,2.476,0,1,1,0,4.953Z" transform="translate(0 -500.393)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
Loading…
Reference in New Issue