Commit e73f061a authored by Menethil's avatar Menethil
Browse files

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

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