Commit 59c91087 authored by 罗超's avatar 罗超

完成分享功能

parent 31a81b7a
......@@ -17,7 +17,9 @@
"delay" : 0
},
/* 模块配置 */
"modules" : {},
"modules" : {
"Share" : {}
},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
......@@ -50,7 +52,14 @@
/* ios打包配置 */
"ios" : {},
/* SDK配置 */
"sdkConfigs" : {}
"sdkConfigs" : {
"share" : {
"weixin" : {
"appid" : "wxacd9f8cc3480d29e",
"UniversalLinks" : ""
}
}
}
}
},
/* 快应用特有相关 */
......
......@@ -22,7 +22,7 @@
</template>
<script>
import auth from "../../components/auth/index.vue";
import auth from "@/components/auth/index";
export default {
props: ['coverPic', 'goodName', 'favorite', 'goodId'],
data() {
......
<template>
<u-popup
mode="bottom"
:border-radius="20"
:popup="false"
v-model="value"
:maskCloseAble="true"
length="auto"
:safeAreaInsetBottom="true"
@close="popupClose"
:z-index="9999"
close-icon="close"
>
<view class="share-box" :style="{ paddingBottom: bianyi ? '50rpx' : '0' }">
<view class="title">分享商品</view>
<view class="goodname">{{ goodName }}</view>
<view class="img-box">
<view class="box">
<image
v-for="(x, i) in images"
:key="i"
:src="x.pic_url"
class="img"
mode="aspectFill"
@click="previewImage(i)"
/>
</view>
</view>
<view class="op-box">
<view class="left">
<text @click="copyHandler">复制文本</text>
<text @click="savePicHandler" style="text-align: center;"
>保存图片</text
>
<text @click="genernalHandler" style="text-align: right;"
>生成海报</text
>
</view>
<view class="right">
<text>分享到</text>
<image
src="/static/images/icon/quan.png"
style="width: 24px; height: 24px;"
@click="sendQuanHandler"
/>
<!-- #ifdef MP-WEIXIN -->
<button open-type="share" style="border: none; outline: none;">
<image
src="/static/images/icon/friend.png"
style="width: 24px; height: 24px;"
/>
</button>
<!-- #endif -->
</view>
</view>
</view>
<u-top-tips ref="uTips"></u-top-tips>
</u-popup>
</template>
<script>
export default {
model: {},
props: {
value: {
type: Boolean,
default: true,
},
id: {
type: Number,
default: 0,
},
goodName: {
type: String,
default: "",
},
images: {
type: Array,
default: [],
},
},
data() {
return {
bianyi: false,
};
},
mounted() {
this.bianyi = this.$uiConfig.is_bang;
},
methods: {
popupClose(){
this.$emit('close')
},
savePicHandler() {
uni.showLoading({
title: "正在下载图片",
});
let arr = JSON.parse(JSON.stringify(this.images));
this.downLoadImage(arr);
},
genernalHandler() {
uni.navigateTo({
url: "/pages/goods/draw",
});
},
sendQuanHandler() {
this.copyHandler();
setTimeout(() => {
this.savePicHandler();
}, 1000);
},
downLoadImage(arr) {
let that = this;
uni.downloadFile({
url: arr[0].pic_url,
success: (res) => {
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function () {
arr.splice(0, 1);
if (arr.length > 0) {
that.downLoadImage(arr);
} else {
uni.hideLoading();
uni.showToast({
title: "下载成功",
});
}
},
fail: function (e) {
uni.hideLoading();
that.$refs.uTips.show({
title: "下载失败,请稍后重试",
type: "error",
duration: "2300",
});
},
});
} else {
uni.hideLoading();
that.$refs.uTips.show({
title: "下载失败,请稍后重试",
type: "error",
duration: "2300",
});
}
},
});
},
copyHandler() {
uni.setClipboardData({
data: this.goodName,
});
},
previewImage(i) {
uni.previewImage({
urls: this.imgs,
current: i,
longPressActions: {
itemList: ["发送给朋友", "保存图片", "收藏"],
success: function (data) {},
fail: function (err) {
console.log(err.errMsg);
},
},
});
},
},
};
</script>
<style>
.share-box {
position: relative;
padding: 20rpx;
padding-bottom: 0;
}
.share-box .title {
font-size: 40rpx;
color: #000;
margin-bottom: 50rpx;
font-weight: 600;
}
.share-box .goodname {
font-size: 28rpx;
line-height: 1.5;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
color: #333;
}
.share-box .img-box {
margin-top: 40rpx;
padding-bottom: 40rpx;
display: block;
border-bottom: 2rpx solid #f1f1f1;
}
.share-box .img-box .box {
white-space: nowrap;
}
.share-box .img-box .box .img {
display: inline-block;
width: 252rpx;
height: 252rpx;
border-radius: 8rpx;
margin-right: 20rpx;
}
.share-box .op-box {
display: flex;
margin: 20rpx 0;
align-items: center;
font-size: 14px;
color: gray;
}
.share-box .op-box .left {
display: flex;
flex: 1;
width: 1rpx;
align-items: center;
}
.share-box .op-box .left text {
flex: 1;
text-align: left;
width: 1rpx;
}
.share-box .op-box .right {
margin-left: 20rpx;
border-left: 2rpx solid #f1f1f1;
display: flex;
align-items: center;
}
.share-box .op-box .right text,
.share-box .op-box .right image {
margin-left: 20rpx;
}
.share-box .op-box .right button {
border: none;
outline: none;
padding: 0;
width: 68rpx;
height: 48rpx;
margin: 0;
line-height: unset;
}
.share-box .op-box .right button::after {
border: none;
}
</style>
......@@ -287,7 +287,7 @@ export default {
this.info = res.data.info;
this.loading = false;
this.generterConfig.bgColor = this.config.color[0];
let temp = 1; //parseInt(this.config.image_style[0]);
let temp = parseInt(this.config.image_style[0]);
for (let i = 0; i < temp; i++) {
this.generterConfig.images.push(this.info.multi_map[i]);
}
......
......@@ -28,11 +28,15 @@
<!-- TODO is_common_user_member_price 普通用户会员价 -->
<!-- TODO is_member_user_member_price 会员用户会员价 -->
<view class="sell u-skeleton-rect">
<text class="oprice" v-if="setting.is_underline_price=='1'">{{ g.original_price }}</text>
<text v-if="setting.is_sales=='1'">已售出{{ g.sales }}{{ g.unit }}</text>
<text class="oprice" v-if="setting.is_underline_price == '1'">{{
g.original_price
}}</text>
<text v-if="setting.is_sales == '1'"
>已售出{{ g.sales }}{{ g.unit }}</text
>
</view>
</view>
<view class="right u-skeleton-rect">
<view class="right u-skeleton-rect" @click="openShare">
<image
src="@/static/images/icon/icon-share.png"
class="share-icon"
......@@ -61,14 +65,21 @@
<view class="label">选择</view>
<view class="content">
<view class="sku-chosen" @click="chosenSku">
<view class="sku">{{ currentSku.attr_list.length>0 ? "已" : "请" }}选择 {{ sku }} </view>
<view class="sku"
>{{ currentSku.attr_list.length > 0 ? "已" : "请" }}选择 {{ sku }}
</view>
<view class="arrow">
<u-icon name="arrow" :size="32" color="#111"></u-icon>
</view>
</view>
<view class="suk-item" style="flex-wrap:wrap">
<view class="suk-item" style="flex-wrap: wrap;">
<template v-if="skuimage.length > 0">
<view v-for="(x, i) in skuimage" class="item img" style="margin-bottom:5px" :key="i">
<view
v-for="(x, i) in skuimage"
class="item img"
style="margin-bottom: 5px;"
:key="i"
>
<image :src="x" style="width: 100%; height: 100%;" />
</view>
<view class="item" v-if="g.attr_groups[0].attr_list.length > 1"
......@@ -79,7 +90,12 @@
</template>
<template v-else>
<template v-for="(x, i) in g.attr_groups[0].attr_list">
<view class="item" v-if="i<5" :key="i" style="margin-bottom:5px">
<view
class="item"
v-if="i < 5"
:key="i"
style="margin-bottom: 5px;"
>
{{ x.attr_name }}
</view>
</template>
......@@ -94,7 +110,7 @@
</view>
</view>
<view class="sku-box u-skeleton-rect" v-if="setting.is_express=='1'">
<view class="sku-box u-skeleton-rect" v-if="setting.is_express == '1'">
<view class="label">快递</view>
<view class="content">
{{ g.express == "" ? "免运费" : g.express }}
......@@ -123,7 +139,7 @@
<view
class="sku-box u-skeleton-rect"
v-if="comments.comments.length == 0 && setting.is_comment=='1'"
v-if="comments.comments.length == 0 && setting.is_comment == '1'"
>
<view class="label">暂无评论信息</view>
</view>
......@@ -202,15 +218,23 @@
mode="favor"
v-if="!isExsitGoods"
></u-empty>
<share
:id="id"
v-if="showShare"
:good-name="g.name"
:images="g.pic_url"
@close="closeShare"
></share>
<!-- <auth></auth> -->
</view>
</template>
<script>
import goodlist from "@/components/goods/list";
import goodsaction from "@/components/goods/goodsaction";
import goodsaction from "./components/goodsaction";
import goodsku from "@/components/goods/goodsku";
import auth from "@/components/auth/index";
import share from "./components/share/share";
export default {
data() {
return {
......@@ -230,10 +254,11 @@ export default {
currentSku: {},
isExsitGoods: true,
pageTitle: "商品详情",
setting:{},
prevPage:"",
//自定义接手传递
opTionObj:{}
setting: {},
prevPage: "",
//自定义接手传递
opTionObj: {},
showShare:false
};
},
components: {
......@@ -241,16 +266,24 @@ export default {
goodsaction,
goodsku,
auth,
share,
},
onLoad(option) {
console.log(option,'optionnnn');
this.opTionObj=option;
this.id = option.GoodsId ? option.GoodsId : 46942; //40887 59512 46942
console.log(option, "optionnnn");
this.opTionObj = option;
this.id = option.GoodsId ? option.GoodsId : 29; //40887 59512 46942
this.init();
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
this.initPage();
this.setting = uni.getStorageSync("basedata").setting
this.setting = uni.getStorageSync("basedata").setting;
},
onShareAppMessage(res) {
return {
title: this.g.name,
path: "/pages/goods/goods?id" + this.id,
imageUrl: this.g.pic_url[0].pic_url,
};
},
methods: {
initPage() {
......@@ -279,11 +312,11 @@ export default {
{
url: "/api/AppletGoods/GetAppletGoodsInfo",
data: {
GoodsId: this.opTionObj.GoodsId
GoodsId: this.id,
},
},
(res) => {
console.log(res,'详情');
console.log(res, "详情");
if (res.resultCode == 1) {
this.g = res.data.goods;
this.g.pic_url.forEach((x) => {
......@@ -302,12 +335,15 @@ export default {
});
console.log(this.skuimage);
var richtext = this.g.detail;
richtext = richtext.replace(/<img/g, '<img style="max-width:100%;height:auto !important;"');
richtext = richtext.replace(
/<img/g,
'<img style="max-width:100%;height:auto !important;"'
);
this.detailContent = richtext;
this.loading = false;
this.initComments();
this.initRecommend();
this.setFootMarkInfo(res.data.goods.id)
this.initRecommend();
this.setFootMarkInfo(res.data.goods.id);
} else {
this.isExsitGoods = false;
}
......@@ -365,19 +401,17 @@ export default {
}
);
},
setFootMarkInfo(id){
this.request2(
{
url: "/api/AppletUser/SetUserFootMarkInfo",
data: {
GoodsId: id,
},
},
(res) => {
}
);
},
setFootMarkInfo(id) {
this.request2(
{
url: "/api/AppletUser/SetUserFootMarkInfo",
data: {
GoodsId: id,
},
},
(res) => {}
);
},
joinCar() {
this.showSku = true;
this.ot = 0;
......@@ -409,6 +443,12 @@ export default {
});
}
},
closeShare() {
this.showShare = false;
},
openShare() {
this.showShare = true;
},
},
};
</script>
......
export default {
install(Vue, options) {
Vue.prototype.host = "https://wx.weibaoge.cn/web/index.php?_mall_id=1285"
Vue.prototype.host2 = "http://192.168.0.110:8200"
//Vue.prototype.host2 = "https://mallApi.oytour.com"
install(Vue, options) {
Vue.prototype.host = "https://wx.weibaoge.cn/web/index.php?_mall_id=1285"
Vue.prototype.host2 = "https://mallApi.oytour.com"
//Vue.prototype.host2 = "https://mallApi.oytour.com"
//Vue.prototype.host2 = "http://mallapi.oytour.com"
Vue.prototype.request = function(param, success, failed) {
//网络请求
uni.request({
url: this.host + "&r=" + param.data.r,
method: param.method || "GET",
header: param.header || {
'content-type': "application/json"
},
data: param.data,
success: res => {
if (res.data.code != 0 && res.data.msg != "商品未上架") {
}
typeof success == "function" && success(res.data);
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
//Vue.prototype.host2 = "http://mallapi.oytour.com"
Vue.prototype.request = function(param, success, failed) {
//网络请求
uni.request({
url: this.host + "&r=" + param.data.r,
method: param.method || "GET",
header: param.header || {
'content-type': "application/json"
},
data: param.data,
success: res => {
if (res.data.code != 0 && res.data.msg != "商品未上架") {
Vue.prototype.request2 = function(param, success, failed) {
//网络请求
uni.request({
url: this.host2 + param.url,
method: param.method || "Post",
header: param.header || {
'content-type': "application/json"
},
data: {
MallBaseId: 1,
TenantId: 1,
OpenId: this.GetOpenId().OpenId,
UserId: this.GetOpenId().UserId,
MiniAppId: this.GetMiniAppId(),
msg: param.data,
token: this.GetOpenId().token
},
success: res => {
if (res.data.resultCode != 1) {
} else {
typeof success == "function" && success(res.data);
}
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
}
typeof success == "function" && success(res.data);
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
// 获取小程序APPID
Vue.prototype.GetMiniAppId = function() {
return 'wxacd9f8cc3480d29e'
}
//获取OpenId
Vue.prototype.GetOpenId = function() {
let mall_userinfo = wx.getStorageSync('mall_UserInfo')
var obj = {
OpenId: '',
UserId: 0,
token:''
}
if (mall_userinfo) {
if (mall_userinfo.OpenId) {
obj.OpenId = mall_userinfo.OpenId;
obj.UserId = mall_userinfo.UserId;
obj.token = mall_userinfo.Token;
}
}
return obj
}
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function(url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
str = url
} else {
str = 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com' + url;
}
return str;
}
}
//价格返回.00
Vue.prototype.getPrice = function(val) {
val = Number(val).toFixed(2);
return val
}
Vue.prototype.request2 = function(param, success, failed) {
//网络请求
uni.request({
url: this.host2 + param.url,
method: param.method || "Post",
header: param.header || {
'content-type': "application/json"
},
data: {
MallBaseId: 1,
TenantId: 1,
OpenId: this.GetOpenId().OpenId,
UserId: this.GetOpenId().UserId,
MiniAppId: this.GetMiniAppId(),
msg: param.data,
token: this.GetOpenId().token
},
success: res => {
if (res.data.resultCode != 1) {
Vue.prototype.apiheader = function() {
return {
'X-Access-Token': '_4Y_WpUZ4a6SI5uJgsZ4Lb7t9mvqJTyr',
'X-App-Platform': 'wxapp',
'X-App-Version': '4.2.47',
'X-Form-Id-List': '[]',
'X-Requested-With': 'XMLHttpRequest',
'X-User-Id': '19992',
'content-type': "application/json"
}
}
}
}
} else {
typeof success == "function" && success(res.data);
}
},
fail: (e) => {
console.log("网络请求fail:" + JSON.stringify(e));
uni.showModal({
content: "" + res.errMsg
});
typeof failed == "function" && failed(res.data);
}
});
}
// 获取小程序APPID
Vue.prototype.GetMiniAppId = function() {
return 'wxacd9f8cc3480d29e'
}
//获取OpenId
Vue.prototype.GetOpenId = function() {
let mall_userinfo = wx.getStorageSync('mall_UserInfo')
var obj = {
OpenId: '',
UserId: 0,
token: ''
}
if (mall_userinfo) {
if (mall_userinfo.OpenId) {
obj.OpenId = mall_userinfo.OpenId;
obj.UserId = mall_userinfo.UserId;
obj.token = mall_userinfo.Token;
}
}
return obj
}
//公用判断图片地址 判断是否包含http
Vue.prototype.getIconLink = function(url) {
let str = ''
if (url && url != '') {
if (url.indexOf('http') != -1) {
str = url
} else {
str = 'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com' + url;
}
return str;
}
}
//价格返回.00
Vue.prototype.getPrice = function(val) {
val = Number(val).toFixed(2);
return val
}
Vue.prototype.apiheader = function() {
return {
'X-Access-Token': '_4Y_WpUZ4a6SI5uJgsZ4Lb7t9mvqJTyr',
'X-App-Platform': 'wxapp',
'X-App-Version': '4.2.47',
'X-Form-Id-List': '[]',
'X-Requested-With': 'XMLHttpRequest',
'X-User-Id': '19992',
'content-type': "application/json"
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment