Browse Source

分享

devlop
mo-bai 4 years ago
parent
commit
2538e4e22e
7 changed files with 351 additions and 223 deletions
  1. 57
      enums/index.js
  2. 15
      manifest.json
  3. 203
      pages/mall/index.vue
  4. 225
      pages/paper-detail/index.vue
  5. BIN
      static/imgs/general/wx-circle-icon.png
  6. BIN
      static/imgs/general/wx-icon.png
  7. 74
      utils/hook.js

57
enums/index.js

@ -3,6 +3,11 @@ const urlEnv = env === 'production' ? '' : `-${env}`
export const XAPPID = '503258978847966403'
export const H5_URL = `http://shopkeeper${env === 'production' ? '' : '.' + env}.qniao.cn`
export const H5_URL_STORE = `${H5_URL}/#/pages/store/index?share=true&`
export const H5_URL_PAPER = `${H5_URL}/#/pages/paper-details/index?share=true&`
/**
* 账号类型
*/
@ -11,7 +16,7 @@ export const accountType = {
PHONE: 2,
EMAIL: 3,
APPLEID: 4,
CUSTOM: 5
CUSTOM: 5,
}
/**
@ -22,7 +27,7 @@ export const codePurpose = {
RESET_LOGIN_PASSWORD: 2,
RESET_PHONE: 3,
BIND_BANK_CARD: 4,
RESET_CREDIT_PASSWORD: 5
RESET_CREDIT_PASSWORD: 5,
}
/**
@ -30,7 +35,7 @@ export const codePurpose = {
*/
export const verificationType = {
PHONE: 1,
EMAIL: 2
EMAIL: 2,
}
/**
* 法大大企业认证状态 1:未认证 2:认证中 3:已认证 4:认证失败
@ -39,14 +44,14 @@ export const fddEnterpriseStatus = {
UNCERTIFIED: 1,
CERTIFIED_ING: 2,
CERTIFIED_SUCCESS: 3,
CERTIFIED_FAIL: 4
CERTIFIED_FAIL: 4,
}
/**
* 上传地址
*/
export const uploadUrl = {
image: `https://api-client-yyt${urlEnv}.qniao.cn/yyt-uec/file-uploading/upload/image`,
file: `https://api-client-yyt${urlEnv}.qniao.cn/yyt-uec/file-uploading/upload/file`
file: `https://api-client-yyt${urlEnv}.qniao.cn/yyt-uec/file-uploading/upload/file`,
}
/**
* 结算周期1月结30飞算1期2月结453月结60飞算2期4月结755月结90飞算3期
@ -54,24 +59,24 @@ export const uploadUrl = {
export const settlementPeriodEnum = [
{
value: 1,
label: '月结30'
label: '月结30',
},
{
value: 2,
label: '月结45'
label: '月结45',
},
{
value: 3,
label: '月结60'
label: '月结60',
},
{
value: 4,
label: '月结75'
label: '月结75',
},
{
value: 5,
label: '月结90'
}
label: '月结90',
},
]
/**
* 结算周期112233
@ -79,16 +84,16 @@ export const settlementPeriodEnum = [
export const fsSettlementPeriodEnum = [
{
value: 1,
label: '1期'
label: '1期',
},
{
value: 2,
label: '2期'
label: '2期',
},
{
value: 3,
label: '3期'
}
label: '3期',
},
]
/**
* 飞算结算方式 1: 先息后本
@ -96,8 +101,8 @@ export const fsSettlementPeriodEnum = [
export const fsSettlementMethodEnum = [
{
value: 1,
label: '先息后本'
}
label: '先息后本',
},
]
/**
@ -107,7 +112,7 @@ export const fsAuditStatus = {
WAIT_APPLY: 0,
AUDITING: 1,
PASS: 2,
REJECT: 3
REJECT: 3,
}
/**
@ -125,7 +130,7 @@ export const supplierOrderStatusEnum = {
FINISHED: 30213,
WAIT_CLIENT_REPAY: 30217,
REPAYING: 30216,
CANCELED: 30212
CANCELED: 30212,
}
/**
* 供应商订单状态 待客户确认订单/30202,待供应商确认订单/30205,待发货/30106,已发货/30107 ,待客户借款/30207,支付中/30208,待客户支付/30214,付款失败/30211,已完成/30213,待客户还款/30217,已取消/30212,还款中/30216
@ -142,7 +147,7 @@ export const supplierOrderStatusMap = {
[supplierOrderStatusEnum.FINISHED]: '已完成',
[supplierOrderStatusEnum.WAIT_CLIENT_REPAY]: '待客户还款',
[supplierOrderStatusEnum.REPAYING]: '还款中',
[supplierOrderStatusEnum.CANCELED]: '已取消'
[supplierOrderStatusEnum.CANCELED]: '已取消',
}
/**
@ -151,13 +156,13 @@ export const supplierOrderStatusMap = {
export const paymentMethodEnum = {
WECHAT_PAY: 1,
MONTHLY_PAY: 2,
FLY_PAY: 4
FLY_PAY: 4,
}
export const paymentMethodMap = {
[paymentMethodEnum.WECHAT_PAY]: '微信支付',
[paymentMethodEnum.MONTHLY_PAY]: '月结支付',
[paymentMethodEnum.FLY_PAY]: '飞算支付'
[paymentMethodEnum.FLY_PAY]: '飞算支付',
}
/**
@ -167,7 +172,7 @@ export const financeStatusEnum = {
WAIT_CLIENT_LOAN: 30181,
WAIT_FINANCE: 30182,
FINISHED: 30183,
FAILED: 30184
FAILED: 30184,
}
/**
@ -177,7 +182,7 @@ export const financeStatusMap = {
[financeStatusEnum.WAIT_CLIENT_LOAN]: '待客户借款',
[financeStatusEnum.WAIT_FINANCE]: '待融资',
[financeStatusEnum.FINISHED]: '已融资',
[financeStatusEnum.FAILED]: '融资失败'
[financeStatusEnum.FAILED]: '融资失败',
}
/**
@ -185,10 +190,10 @@ export const financeStatusMap = {
*/
export const contractTypeEnum = {
ORDER_CONTRACT: 1,
GUARANTEE_CONTRACT: 2
GUARANTEE_CONTRACT: 2,
}
export const contractTypeMap = {
[contractTypeEnum.ORDER_CONTRACT]: '订单合同',
[contractTypeEnum.GUARANTEE_CONTRACT]: '担保合同'
[contractTypeEnum.GUARANTEE_CONTRACT]: '担保合同',
}

15
manifest.json

@ -28,7 +28,9 @@
"Geolocation" : {},
"FaceID" : {},
"iBeacon" : {},
"Push" : {}
"Push" : {},
"Share" : {},
"Payment" : {}
},
/* */
"distribute" : {
@ -80,8 +82,8 @@
"payment" : {
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "",
"UniversalLinks" : ""
"appid" : "wxbdd9c878b33e451d",
"UniversalLinks" : "https://apple-app-yyt-shopkeeper.qniao.cn/"
}
},
"ad" : {},
@ -92,7 +94,12 @@
"appkey_android" : "877848546f7f3717101a17c33e1d4df3"
}
},
"share" : {},
"share" : {
"weixin" : {
"appid" : "wxbdd9c878b33e451d",
"UniversalLinks" : "https://apple-app-yyt-shopkeeper.qniao.cn/"
}
},
"push" : {
"unipush" : {}
}

203
pages/mall/index.vue

@ -75,53 +75,35 @@
</view>
<view class="flex-col section_4" v-show="visible">
<image src="/static/imgs/mall/close-icon.png" class="image_9" @click="closeShare" />
<!-- <view class="flex-col section_5">
<view class="flex-col section_6">
<view class="flex-col items-center group_13">
<image src="/static/imgs/mall/border-bg.png" class="image_10" />
<image :src="shareInfo.storeCodeImg" class="image_11" />
</view>
<view class="flex-col items-center group_14">
<text class="text_15">{{ shareInfo.storeName }}</text>
<text class="text_16">每天上新特价纸库存有限先到先得</text>
</view>
</view>
</view> -->
<image style="width: 560rpx; height: 710rpx" :src="shareInfo.storeCodeImg"></image>
<view class="bottom-group flex-row view_3">
<text>下载海报</text>
<text class="text_18">下载二维码</text>
<text class="text_19">分享</text>
<view class="bottom-group flex-row justify-center view_3">
<text @click="downPoster">下载海报</text>
<text @click="showShareArea" class="text_19">分享</text>
</view>
</view>
<!-- <view class="share-area" v-if="visible" @click="closeShare">
<view class="share-content">
<image class="bg" src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/qrCode-bg.png"></image>
<view class="flex-col-center-start code">
<view class="border flex-row-center-center">
<image style="width: 480rpx; height: 480rpx" :src="shareInfo.storeCodeImg"></image>
</view>
<view class="down-button flex-row-center-center" @click.stop="makeScreenShot">
<text class="text">下载二维码</text>
</view>
<text style="font-size: 46rpx; color: #333333">{{ shareInfo.storeName }}</text>
<text style="font-size: 32rpx; color: #888888; margin-top: 14rpx">每天上新特价纸库存有限先到先得</text>
<view class="flex-col section_8" v-if="shareAreaVisible">
<view class="flex-row group_20">
<view class="flex-col items-center" @click="sharePoster('WXSceneSession')">
<image src="/static/imgs/general/wx-icon.png" class="image_13" />
<text class="text_33">微信</text>
</view>
<view class="flex-col group_22" @click="sharePoster('WXSceneTimeline')">
<image src="/static/imgs/general/wx-circle-icon.png" class="image_13 image_15" />
<text class="text_34">朋友圈</text>
</view>
</view>
</view> -->
<!-- <view v-if="visible" @click="closeShare">
<web-view :webview-styles="webviewStyles" src="/hybrid/html/share.html"></web-view>
</view> -->
</view>
</view>
</template>
<script>
import notLogged from '@/components/not-logged/not-logged.vue'
import uGap from '@/components/u-gap/u-gap.vue'
import { back, go2, loginGo2, saveImage } from '@/utils/hook.js'
import { back, go2, loginGo2, saveImage, saveBase64ToTempFile } from '@/utils/hook.js'
import { SupplierList, productStatus, storeDetail, getSupplierQrCode } from '@/apis/add-paper.js'
import { getTimer } from '@/utils/index.js'
import noData from './no-data.vue'
import { H5_URL_STORE } from '@/enums/index.js'
export default {
components: { uGap, noData, notLogged },
filters: {
@ -131,31 +113,31 @@ export default {
abs = getTimer(value)
}
return abs
}
},
},
data() {
return {
shareInfo: {
storeCodeImg: '',
storeName: ''
storeName: '',
},
visible: false, //
canvasReady: false,
shareAreaVisible: false, //
storeInformation: {
supplierId: null,
name: null,
productNumber: 0,
currentProductNumber: 0
currentProductNumber: 0,
},
option: {
size: 10,
auto: true,
emptyText: '暂无数据~',
disabled: false
disabled: false,
},
pattern: {
backgroundColor: '#007AFF',
buttonColor: '#007AFF'
buttonColor: '#007AFF',
},
content: [],
horizontal: 'right',
@ -166,12 +148,12 @@ export default {
pageSize: 10,
storeId: null,
name: null,
supplierId: this.$store.state.supplierInfo.supplierId
supplierId: this.$store.state.supplierInfo.supplierId,
},
listData: [],
logo: '/static/imgs/mine/user-avatar.png',
backgroundStyle: 'background: url("/static/imgs/mall/top-bg.png") no-repeat;',
storeInfo: ''
storeInfo: '',
}
},
computed: {
@ -180,12 +162,12 @@ export default {
},
hasLogin() {
return this.$store.state.qnToken != ''
}
},
},
onShow() {
if (this.hasCompany) {
this.storeInformation = {
supplierId: this.$store.state.supplierInfo.supplierId
supplierId: this.$store.state.supplierInfo.supplierId,
}
this.downCallback()
this.getSupplier(this.$store.state.supplierInfo.supplierId)
@ -267,7 +249,7 @@ export default {
//
nativeTo() {
var params = {
title: '添加纸品'
title: '添加纸品',
}
go2('add-paper', params)
},
@ -275,7 +257,7 @@ export default {
editPaper(item) {
var params = {
...item,
title: '编辑纸品'
title: '编辑纸品',
}
go2('add-paper', params)
},
@ -291,13 +273,13 @@ export default {
productStatusChange(item) {
var params = {
id: item.id,
status: item.status === 30111 ? 30112 : 30111
status: item.status === 30111 ? 30112 : 30111,
}
productStatus(params).then((res) => {
if (res) {
uni.showToast({
title: '状态修改成功',
icon: 'success'
icon: 'success',
})
setTimeout(() => {
this.orderPagination.pageNum = 1
@ -313,26 +295,49 @@ export default {
return
}
getSupplierQrCode({
mallSupplierId: this.$store.state.supplierInfo.supplierId
mallSupplierId: this.$store.state.supplierInfo.supplierId,
}).then((res) => {
if (res) {
this.visible = true
this.shareInfo.storeCodeImg = `data:image/png;base64,${res}`
this.shareInfo.storeName = this.storeInformation.name
saveImage(this.shareInfo.storeCodeImg)
}
})
} else {
uni.showToast({
title: '请先完善企业信息',
icon: 'none'
icon: 'none',
})
}
},
closeShare() {
this.visible = false
}
}
this.shareAreaVisible = false
},
downPoster() {
saveImage(this.shareInfo.storeCodeImg)
},
sharePoster(scene) {
uni.share({
provider: 'weixin',
type: 0,
title: this.shareInfo.storeName,
summary: '点击进入我的商城\n限时特价等你来抢!',
scene: scene, // WXSceneTimeline,WXSceneSession
imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/wx-share-store.png',
href: H5_URL_STORE + `id=${this.$store.state.supplierInfo.supplierId}`,
success: () => {
console.log('分享成功')
},
fail: (err) => {
console.log('err', err)
},
})
},
showShareArea() {
this.shareAreaVisible = true
},
},
}
</script>
@ -509,58 +514,6 @@ export default {
height: 100rpx;
}
}
.share-area {
width: 750rpx;
height: 100vh;
background: #888888;
position: fixed;
z-index: 998;
top: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.share-content {
width: 750rpx;
background-color: #fff;
border-radius: 20rpx;
padding: 64rpx 34rpx 70rpx;
position: relative;
.bg {
position: absolute;
top: 0;
left: 0;
width: 750rpx;
height: 944rpx;
}
.code {
position: relative;
z-index: 10;
background-color: #fff;
width: 680rpx;
border-radius: 20rpx;
box-shadow: 0px 3rpx 13rpx 0px rgba(0, 0, 0, 0.1);
padding: 40rpx 70rpx 64rpx;
.border {
width: 540rpx;
height: 540rpx;
background: url('https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/qrCode-border.png') no-repeat center/cover;
}
}
.down-button {
width: 540rpx;
height: 90rpx;
margin: 40rpx 0 76rpx;
background-image: linear-gradient(180deg, #6092ec 0%, #225dd4 100%);
border-radius: 45rpx;
.text {
font-size: 48rpx;
color: #ffffff;
}
}
}
}
.section_4 {
z-index: 100;
padding: 252rpx 36rpx 403rpx 95rpx;
@ -628,11 +581,9 @@ export default {
}
.bottom-group {
padding: 0 32rpx;
.text_18 {
margin-left: 83rpx;
}
.text_19 {
margin-left: 83rpx;
margin-right: 62rpx;
}
}
.view_3 {
@ -644,9 +595,39 @@ export default {
white-space: nowrap;
}
}
#posters {
margin-top: 15px;
padding: 60rpx 0;
border-radius: 20rpx;
.section_8 {
position: fixed;
z-index: 999;
bottom: 0;
left: 0;
right: 0;
margin-top: 213rpx;
padding: 32rpx 0 52rpx;
color: rgb(0, 0, 0);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
background-color: rgb(255, 255, 255);
border-radius: 20rpx 20rpx 0px 0px;
.group_20 {
margin: 0 32rpx;
.group_22 {
margin-left: 36rpx;
flex: 1 1 auto;
.image_15 {
margin-left: 4rpx;
}
.text_34 {
margin-top: 10rpx;
}
}
.text_33 {
margin-top: 10rpx;
}
.image_13 {
width: 64rpx;
height: 64rpx;
}
}
}
</style>

225
pages/paper-detail/index.vue

@ -81,18 +81,23 @@
<text>{{ form.otherNote }}</text>
</view>
</view>
<view class="share-area" v-if="visible" @click="closeShare">
<view class="share-content">
<image class="bg" src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/qrCode-bg.png"></image>
<view class="flex-col-center-start code">
<view class="border flex-row-center-center">
<image style="width: 480rpx; height: 480rpx" :src="shareInfo.storeCodeImg"></image>
</view>
<view class="down-button flex-row-center-center" @click.stop="makeScreenShot">
<text class="text">下载二维码</text>
</view>
<text style="font-size: 46rpx; color: #333333">{{ shareInfo.storeName }}</text>
<text style="font-size: 32rpx; color: #888888; margin-top: 14rpx">{{ shareInfo.paperName }}</text>
<view class="flex-col section_4" v-show="visible">
<image src="/static/imgs/mall/close-icon.png" class="image_9" @click="closeShare" />
<image style="width: 560rpx; height: 710rpx" :src="shareInfo.storeCodeImg"></image>
<view class="bottom-group flex-row justify-center view_3">
<text @click="downPoster">下载海报</text>
<text @click="showShareArea" class="text_19">分享</text>
</view>
</view>
<view class="flex-col section_8" v-if="shareAreaVisible">
<view class="flex-row group_20">
<view class="flex-col items-center" @click="sharePoster('WXSceneSession')">
<image src="/static/imgs/general/wx-icon.png" class="image_13" />
<text class="text_33">微信</text>
</view>
<view class="flex-col group_22" @click="sharePoster('WXSceneTimeline')">
<image src="/static/imgs/general/wx-circle-icon.png" class="image_13 image_15" />
<text class="text_34">朋友圈</text>
</view>
</view>
</view>
@ -100,25 +105,27 @@
</template>
<script>
import { back, go2 } from '@/utils/hook.js'
import { back, saveImage, saveBase64ToTempFile } from '@/utils/hook.js'
import uGap from '@/components/u-gap/u-gap.vue'
import { H5_URL_PAPER } from '@/enums/index.js'
import { getSupplierDetail, getPaperQrCode } from '@/apis/add-paper.js'
export default {
components: {
uGap
uGap,
},
data() {
return {
shareInfo: {
storeCodeImg: '',
storeName: '',
paperName: ''
paperName: '',
},
visible: false, //
shareAreaVisible: false, //
form: {},
skuList: [],
imgList: [],
id: null
id: null,
}
},
onLoad(option) {
@ -133,7 +140,7 @@ export default {
setTimeout(() => {
back()
}, 2000)
}
},
})
}
},
@ -143,7 +150,7 @@ export default {
getDetailList() {
var params = {
mallSupplierIds: this.$store.state.supplierInfo.supplierId,
productId: this.id
productId: this.id,
}
getSupplierDetail(params).then((res) => {
if (res) {
@ -175,8 +182,32 @@ export default {
},
closeShare() {
this.visible = false
}
}
this.shareAreaVisible = false
},
downPoster() {
saveImage(this.shareInfo.storeCodeImg)
},
sharePoster(scene) {
uni.share({
provider: 'weixin',
type: 0,
title: this.shareInfo.paperName,
summary: '纸厂: ' + this.shareInfo.storeName,
scene: scene, // WXSceneTimeline,WXSceneSession
imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/wx-share-paper.png',
href: H5_URL_PAPER + `id=${this.$store.state.supplierInfo.supplierId}&paperId=${this.id}`,
success: () => {
console.log('分享成功')
},
fail: (err) => {
console.log('err', err)
},
})
},
showShareArea() {
this.shareAreaVisible = true
},
},
}
</script>
@ -245,68 +276,132 @@ export default {
background: #f7f8fa;
}
.paper-list-view {
line-height: 40rpx;
padding: 0rpx 32rpx 32rpx;
}
.paper-datail-list-image {
width: 120rpx;
height: 120rpx;
padding: 32rpx 32rpx;
margin-right: 24rpx;
}
}
.paper-bottom-border {
border-bottom: 2rpx solid #d8d8d8;
}
}
.share-area {
width: 750rpx;
height: 100vh;
background: #888888;
position: fixed;
z-index: 998;
.section_4 {
z-index: 100;
padding: 252rpx 36rpx 403rpx 95rpx;
background-color: rgba(0, 0, 0, 0.5);
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.share-content {
width: 750rpx;
background-color: #fff;
position: absolute;
.image_9 {
align-self: flex-end;
width: 62rpx;
height: 62rpx;
}
.section_5 {
margin-top: 30rpx;
padding: 60rpx 0;
border-radius: 20rpx;
padding: 64rpx 34rpx 70rpx;
position: relative;
.bg {
position: absolute;
top: 0;
left: 0;
width: 750rpx;
height: 944rpx;
}
.code {
position: relative;
z-index: 10;
background-color: #fff;
width: 680rpx;
border-radius: 20rpx;
box-shadow: 0px 3rpx 13rpx 0px rgba(0, 0, 0, 0.1);
padding: 40rpx 70rpx 64rpx;
.border {
width: 540rpx;
height: 540rpx;
background: url('https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/qrCode-border.png') no-repeat center/cover;
background-image: url('/static/imgs/mall/qrCode-bg.png');
background-size: 100% 100%;
background-repeat: no-repeat;
width: 560rpx;
.section_6 {
margin: 0 32rpx;
padding: 50rpx 56rpx 0;
background-color: rgb(255, 255, 255);
box-shadow: 0px 2rpx 10rpx 0px rgba(0, 0, 0, 0.1);
border-radius: 16rpx;
width: 496rpx;
.group_13 {
margin: 0 12rpx;
position: relative;
.image_10 {
width: 360rpx;
height: 360rpx;
}
.image_11 {
width: 330rpx;
height: 330rpx;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
.group_14 {
padding: 40rpx 0 56rpx;
.text_15 {
color: rgb(51, 51, 51);
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
white-space: nowrap;
}
.text_16 {
margin-top: 10rpx;
color: rgb(136, 136, 136);
font-size: 24rpx;
font-weight: 500;
line-height: 33rpx;
white-space: nowrap;
}
}
}
.down-button {
width: 540rpx;
height: 90rpx;
margin: 40rpx 0 76rpx;
background-image: linear-gradient(180deg, #6092ec 0%, #225dd4 100%);
border-radius: 45rpx;
.text {
font-size: 48rpx;
color: #ffffff;
}
.bottom-group {
padding: 0 32rpx;
.text_19 {
margin-left: 83rpx;
margin-right: 62rpx;
}
}
.view_3 {
margin-top: 40rpx;
color: rgb(255, 255, 255);
font-size: 30rpx;
font-weight: 500;
line-height: 42rpx;
white-space: nowrap;
}
}
.section_8 {
position: fixed;
z-index: 999;
bottom: 0;
left: 0;
right: 0;
margin-top: 213rpx;
padding: 32rpx 0 52rpx;
color: rgb(0, 0, 0);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
background-color: rgb(255, 255, 255);
border-radius: 20rpx 20rpx 0px 0px;
.group_20 {
margin: 0 32rpx;
.group_22 {
margin-left: 36rpx;
flex: 1 1 auto;
.image_15 {
margin-left: 4rpx;
}
.text_34 {
margin-top: 10rpx;
}
}
.text_33 {
margin-top: 10rpx;
}
.image_13 {
width: 64rpx;
height: 64rpx;
}
}
}
</style>

BIN
static/imgs/general/wx-circle-icon.png

Before After
Width: 128  |  Height: 128  |  Size: 11 KiB

BIN
static/imgs/general/wx-icon.png

Before After
Width: 128  |  Height: 128  |  Size: 9.4 KiB

74
utils/hook.js

@ -221,22 +221,62 @@ export function screenShot() {
* @param {string} base64 图片base64
*/
export function saveImage(base64) {
uni.saveImageToPhotosAlbum({
filePath: base64,
success: function () {
uni.showToast({
title: '保存图片成功',
mask: false,
duration: 1500,
})
},
fail: function (err) {
console.log(err)
uni.showToast({
title: '保存图片失败,请手动截图',
mask: false,
duration: 1500,
})
},
saveBase64ToTempFile(base64).then((url) => {
saveImageToPhotosAlbum(url)
})
}
/**
* 将base64保存为临时文件并返回文件路径
* @param {string} base64
* @returns
*/
export function saveBase64ToTempFile(base64) {
return new Promise((resolve, reject) => {
const bitmap = new plus.nativeObj.Bitmap('img')
bitmap.loadBase64Data(base64, () => {
const url = '_doc/' + new Date().getTime() + '.png'
bitmap.save(
url,
{
overwrite: true,
},
() => {
bitmap.clear()
resolve(url)
},
(e) => {
reject(e)
}
)
})
})
}
/**
* 保存图片到相册
* @param {string} path 图片路径
*/
export function saveImageToPhotosAlbum(path) {
return new Promise((resolve, reject) => {
uni.saveImageToPhotosAlbum({
filePath: path,
success: (res) => {
uni.showToast({
title: '保存图片成功',
mask: false,
duration: 1500,
})
resolve()
},
fail: (err) => {
uni.showToast({
title: '保存图片失败,请手动截图',
mask: false,
duration: 1500,
})
resolve()
},
})
})
}
Loading…
Cancel
Save