| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <template>
- <view class="kefu">
- <view class="kf">
- <!-- #ifdef H5 -->
- <image :src="kefu_img" class="kfimg"></image>
- <!-- #endif -->
- <!-- #ifdef MP -->
- <image :src="kefu_img" @longpress="savePosterPath(kefu_img)" class="kfimg"></image>
- <!-- #endif -->
- <view class="kftext">
- {{kefu_text}}
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getArticleDetails
- } from '@/api/api.js'
- export default {
- data() {
- return {
- kefu_img: '',
- kefu_text: '',
- }
- },
- onLoad() {
- this.getKefuInfo()
- },
- methods: {
- getKefuInfo() {
- getArticleDetails(151, {}).then(({
- data
- }) => {
- this.kefu_img = data.image_input
- this.kefu_text = data.synopsis
- uni.setNavigationBarTitle({
- title: data.title
- })
- })
- },
- // #ifdef MP
- // 小程序保存图片
- savePosterPath(url) {
- uni.downloadFile({
- url,
- success: (resFile) => {
- console.log(resFile, "resFile");
- if (resFile.statusCode === 200) {
- uni.getSetting({
- success: (res) => {
- if (!res.authSetting["scope.writePhotosAlbum"]) {
- uni.authorize({
- scope: "scope.writePhotosAlbum",
- success: () => {
- uni.saveImageToPhotosAlbum({
- filePath: resFile.tempFilePath,
- success: (res) => {
- return uni.showToast({
- title: "保存成功!",
- });
- },
- fail: (res) => {
- return uni.showToast({
- title: res.errMsg,
- });
- },
- complete: (res) => {},
- });
- },
- fail: () => {
- uni.showModal({
- title: "您已拒绝获取相册权限",
- content: "是否进入权限管理,调整授权?",
- success: (res) => {
- if (res.confirm) {
- uni.openSetting({
- success: (res) => {
- console.log(res.authSetting);
- },
- });
- } else if (res.cancel) {
- return uni.showToast({
- title: "已取消!",
- });
- }
- },
- });
- },
- });
- } else {
- uni.saveImageToPhotosAlbum({
- filePath: resFile.tempFilePath,
- success: (res) => {
- return uni.showToast({
- title: "保存成功!",
- });
- },
- fail: (res) => {
- return uni.showToast({
- title: res.errMsg,
- });
- },
- complete: (res) => {},
- });
- }
- },
- fail: (res) => {},
- });
- } else {
- return uni.showToast({
- title: resFile.errMsg,
- });
- }
- },
- fail: (res) => {
- return uni.showToast({
- title: res.errMsg,
- });
- },
- });
- },
- // #endif
- }
- }
- </script>
- <style scoped lang="scss">
- .kefu {
- position: fixed;
- background-color: #f5f5f5;
- height: 100%;
- width: 100%;
- .kf {
- height: 500rpx;
- width: 500rpx;
- position: absolute;
- // background-color: #bfa;
- top: 0;
- right: 0;
- left: 0;
- bottom: 0;
- margin: auto;
- .kfimg {
- display: block;
- margin: 0 auto;
- width: 400rpx;
- height: 400rpx;
- }
- .kftext {
- padding-top: 20rpx;
- font-size: 32rpx;
- text-align: center;
- }
- }
- // .kftext {
- // font-size: 32rpx;
- // height: 50rpx;
- // width: 750rpx;
- // position: absolute;
- // top: 0;
- // right: 0;
- // left: 0;
- // bottom: 0;
- // margin:50rpx auto 0;
- // }
- }
-
- </style>
|