Commit e73f061a authored by Menethil's avatar Menethil
Browse files

添加小程序朋友圈分享,朋友分享,并实现首页自动跳转

parent 0881acf4
......@@ -22,11 +22,6 @@
</el-form-item>
<el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">登录</el-button>
<div class="tips">
<span>管理员用户名 : admin123</span>
<span>管理员密码 : admin123</span>
</div>
</el-form>
</div>
......@@ -52,8 +47,8 @@ export default {
}
return {
loginForm: {
username: 'admin123',
password: 'admin123'
username: '',
password: ''
},
loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
......
// 以下是业务服务器API地址
// 本机开发时使用
var WxApiRoot = 'http://localhost:8082/wx/';
// var WxApiRoot = 'http://localhost:8082/wx/';
// 局域网测试使用
// var WxApiRoot = 'http://192.168.0.101:8082/wx/';
// 云平台部署时使用
// var WxApiRoot = 'http://122.152.206.172:8082/wx/';
// 云平台上线时使用
// var WxApiRoot = 'https://www.menethil.com.cn/wx/';
var WxApiRoot = 'https://www.menethil.com.cn/wx/';
module.exports = {
IndexUrl: WxApiRoot + 'home/index', //首页数据接口
......
......@@ -25,6 +25,7 @@ Page({
noCollectImage: '/static/images/icon_collect.png',
hasCollectImage: '/static/images/icon_collect_checked.png',
collectImage: '/static/images/icon_collect.png',
shareImage: '',
soldout: false
},
......@@ -35,6 +36,39 @@ Page({
wx.stopPullDownRefresh() //停止下拉刷新
},
saveShare: function() {
let that = this;
wx.downloadFile({
url: that.data.shareImage,
success: function(res) {
console.log(res)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function(res) {
wx.showModal({
title: '存图成功',
content: '图片成功保存到相册了,可以分享到朋友圈了',
showCancel: false,
confirmText: '好的',
confirmColor: '#a78845',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
}
}
})
},
fail: function(res) {
console.log('fail')
}
})
},
fail: function() {
console.log('fail')
}
})
},
getGoodsInfo: function() {
let that = this;
util.request(api.GoodsDetail, {
......@@ -72,6 +106,7 @@ Page({
specificationList: res.data.specificationList,
productList: res.data.productList,
userHasCollect: res.data.userHasCollect,
shareImage: res.data.shareImage,
checkedSpecPrice: res.data.info.retailPrice
});
......
......@@ -4,11 +4,10 @@
<image src="{{item}}" background-size="cover"></image>
</swiper-item>
</swiper>
<view class="service-policy">
<view class="item">30天无忧退货</view>
<view class="item">48小时快速退款</view>
<view class="item">满88元免邮费</view>
</view>
<view class="service-policy">
<button class="savesharebtn" bindtap="saveShare">分享朋友圈</button>
<button class="sharebtn" open-type="share">分享给朋友</button>
</view>
<view class="goods-info">
<view class="c">
<text class="name">{{goods.name}}</text>
......
......@@ -12,7 +12,7 @@
height: 750rpx;
}
.service-policy {
/* .service-policy {
width: 750rpx;
height: 73rpx;
background: #f4f4f4;
......@@ -31,7 +31,7 @@
align-items: center;
font-size: 25rpx;
color: #666;
}
} */
.goods-info {
width: 750rpx;
......@@ -782,3 +782,45 @@
color: #fff;
text-align: center;
}
.service-policy {
width: 100%;
height: 96rpx;
/* background: #d3b676; */
border: 2px solid #fff;
/* align-items: center; */
}
.service-policy .sharebtn {
width: 49.5%;
float: right;
border: none;
height: 80rpx;
font-size: 32rpx;
background: #d3b676;
text-align: center;
color: #fff;
border-radius:0%;
}
.service-policy .sharebtn::after {
border: none;
border-radius:0%;
}
.service-policy .savesharebtn {
width: 49.5%;
float: left;
border: none;
height: 80rpx;
font-size: 32rpx;
background: #d3b676;
text-align: center;
color: #fff;
border-radius:0%;
}
.service-policy .savesharebtn::after {
border: none;
border-radius:0%;
}
\ No newline at end of file
......@@ -5,59 +5,87 @@ const user = require('../../utils/user.js');
//获取应用实例
const app = getApp()
Page({
data: {
newGoods: [],
hotGoods: [],
topics: [],
brands: [],
floorGoods: [],
banner: [],
channel: []
},
onShareAppMessage: function() {
return {
title: 'litemall小程序商场',
desc: '开源微信小程序商城',
path: '/pages/index/index'
}
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getIndexData();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getIndexData: function() {
let that = this;
util.request(api.IndexUrl).then(function(res) {
if (res.errno === 0) {
that.setData({
newGoods: res.data.newGoodsList,
hotGoods: res.data.hotGoodsList,
topics: res.data.topicList,
brands: res.data.brandList,
floorGoods: res.data.floorGoodsList,
banner: res.data.banner,
channel: res.data.channel
});
}
data: {
newGoods: [],
hotGoods: [],
topics: [],
brands: [],
floorGoods: [],
banner: [],
channel: []
},
onShareAppMessage: function() {
return {
title: 'litemall小程序商场',
desc: '开源微信小程序商城',
path: '/pages/index/index'
}
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getIndexData();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getIndexData: function() {
let that = this;
util.request(api.IndexUrl).then(function(res) {
if (res.errno === 0) {
that.setData({
newGoods: res.data.newGoodsList,
hotGoods: res.data.hotGoodsList,
topics: res.data.topicList,
brands: res.data.brandList,
floorGoods: res.data.floorGoodsList,
banner: res.data.banner,
channel: res.data.channel
});
},
onLoad: function(options) {
this.getIndexData();
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
},
}
});
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
if (options.scene) {
//这个scene的值存在则证明首页的开启来源于朋友圈分享的图,同时可以通过获取到的goodId的值跳转导航到对应的详情页
var scene = decodeURIComponent(options.scene);
console.log("scene:" + scene);
wx.navigateTo({
url: '../goods/goods?id=' + scene
});
}
// 页面初始化 options为页面跳转所带来的参数
if (options.goodId) {
//这个goodId的值存在则证明首页的开启来源于分享,同时可以通过获取到的goodId的值跳转导航到对应的详情页
wx.navigateTo({
url: '../goods/goods?id=' + options.goodId
});
}
// 页面初始化 options为页面跳转所带来的参数
if (options.orderId) {
//这个orderId的值存在则证明首页的开启来源于订单模版通知,同时可以通过获取到的pageId的值跳转导航到对应的详情页
wx.navigateTo({
url: '../ucenter/orderDetail/orderDetail?id=' + options.orderId
});
}
this.getIndexData();
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
},
})
\ No newline at end of file
Supports Markdown
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