Browse Source

app图片长按保存

master
Aaron 4 years ago
parent
commit
3a1ce61f97
  1. 2
      manifest.json
  2. 39
      pages/activity/Poster/index.vue
  3. 4
      pages/user/User/index.vue
  4. 1
      store/index.js

2
manifest.json

@ -131,7 +131,7 @@
"setting" : { "setting" : {
"urlCheck" : true, "urlCheck" : true,
"postcss" : true, "postcss" : true,
"minified" : false "minified" : true
}, },
"usingComponents" : true, "usingComponents" : true,
"permission" : { "permission" : {

39
pages/activity/Poster/index.vue

@ -1,10 +1,17 @@
<template> <template>
<view class="poster-poster" v-if="status === false"> <view class="poster-poster" v-if="status === false">
<view class="tip"> <view class="tip">
<text class="iconfont icon-shuoming"></text>提示长按图片保存至手机相册 <!-- #ifndef H5 -->
<text class="iconfont icon-shuoming"></text>提示长按图片保存至手机相册
<!-- #endif -->
</view> </view>
<view class="poster"> <view class="poster">
<image :src="image" mode="widthFix" @longtap="longtap" show-menu-by-longpress /> <!-- #ifndef APP-PLUS -->
<image :src="image" mode="widthFix" show-menu-by-longpress />
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<image :src="image" mode="widthFix" @longtap="longtap"/>
<!-- #endif -->
</view> </view>
</view> </view>
</template> </template>
@ -22,7 +29,8 @@
return { return {
status: true, status: true,
id: 0, id: 0,
image: "" image: "",
img: 'https://img-blog.csdnimg.cn/20190626120443986.png'
}; };
}, },
mounted () { mounted () {
@ -84,8 +92,29 @@
}); });
}); });
}, },
// // app
longtap () {} longtap () {
//
uni.downloadFile({
url: this.img,
success: (res) => {
//
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
uni.showToast({
title: "保存成功!",
});
},
fail: () => {
uni.showToast({
title: "保存失败",
});
},
});
},
});
}
} }
}; };
</script> </script>

4
pages/user/User/index.vue

@ -64,7 +64,7 @@
<text class="iconfont icon-jiantou"></text> <text class="iconfont icon-jiantou"></text>
</text> </text>
</view> </view>
<view class="orderState acea-row row-middle"> <view class="orderState acea-row row-middle" v-if="userInfo.orderStatusNum !== undefined || userInfo.orderStatusNum !== null">
<view @click="goMyOrder(0)" class="item"> <view @click="goMyOrder(0)" class="item">
<view class="pictrue"> <view class="pictrue">
<image :src="`${$VUE_APP_RESOURCES_URL}/images/dfk.png`" /> <image :src="`${$VUE_APP_RESOURCES_URL}/images/dfk.png`" />
@ -336,7 +336,7 @@ export default {
}, },
// //
MenuUser() { MenuUser() {
getMenuUser() getMenuUser()
.then(res => { .then(res => {
uni.hideLoading() uni.hideLoading()
this.MyMenus = res.data.routine_my_menus this.MyMenus = res.data.routine_my_menus

1
store/index.js

@ -29,6 +29,7 @@ const vuexStore = new Vuex.Store({
}, },
mutations: { mutations: {
login(state, token, expires_time) { login(state, token, expires_time) {
console.log('设置token')
state.token = token state.token = token
cookie.set(loginKey, token, expires_time) cookie.set(loginKey, token, expires_time)
}, },

Loading…
Cancel
Save