Commit 65c3e7c1 by 李静静

小程序卡片

parent 7843a4db
......@@ -3,9 +3,6 @@
"pages/index/index",
"pages/freeCourse/index",
"pages/joinGroup/index",
"pages/weibanzhushou/index",
"pages/yinliu/externalLink",
"pages/youzan/index",
"pages/joinGroupH5/index",
"pages/card/index"
],
......
......@@ -27,7 +27,8 @@ Page({
tooltipsImg:wx.getStorageSync("tooltipsImg")===false?false:true,
tooltipsMenus:wx.getStorageSync("tooltipsMenus")===false?false:true,
cardData:[], //页面内容的大数组,可能有95个吧
curCardData:{}
curCardData:{},
xcx_token:wx.getStorageSync('xcx_token')||'',
},
onClickNav({ detail = {} }) {
this.setData({
......@@ -44,12 +45,15 @@ Page({
onSelectItem: function (event) {
console.log(event);
var item = event.currentTarget.dataset.item;
if((!this.data.xcx_token)&&item.disabled){
console.log('正在授权手机号');
return;
}
// this.$emit('click-item', item);
if(item.disabled){
wx.showToast({
icon:'none',
title:'该卡片暂未开放!'
title:'您暂时没有查看权限'
})
return
}
......@@ -73,7 +77,9 @@ Page({
wx.reportAnalytics('chang_card', {
scene: activeSceneId
});
wx.reportEvent('chang_card', {
scene: activeSceneId
});
this.gotoTop();
}
......@@ -81,21 +87,31 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.hideShareMenu();
console.log(options)
// this.setData({
// url: host+'/xcx/wz/unit_card?id='+(options.scene||1)
// //url: host+'/h5/app3/product/common?id='+(options.scene|7)
// })
// this.getData(options.scene);
this.getMenusData(options.scene)
this.setData({
from:options.from||""
})
async onLoad (options) {
let tokenData
//扫码进来的,不用管token,都能看
if(!options.from){
wx.setStorageSync('no_locked',1)
}else{
if((!this.data.xcx_token)&&options.token){
tokenData = await this.getToken(options.token); //拿app的token获取小程序的token;
wx.setStorageSync('xcx_token',tokenData)
wx.removeStorageSync("app_token");
this.setData({
xcx_token:tokenData
})
}
}
let resultData=await this.getMenusData()
this.formatMenusData(resultData,options.scene||1);
this.setData({
from:options.from||""
})
},
// getEndEle:wx.createSelectorQuery(),
endLineDOM(){
......@@ -109,62 +125,100 @@ Page({
}
}).exec()
},
getMenusData(scene){
let mainActiveIndex;
request({
url:"/xcx/wz/card_tree",
success:(res)=>{
console.log(res.data)
if(res.data&&res.data.code===0){
// console.log(res.data.data.list)
let subjects=res.data.data.subjects;
let subjectObj={}
let subjectArr=subjects.forEach((i,idx)=>{
subjectObj[i]={
text:i,
key:idx
}
})
const no_locked = wx.getStorageSync('no_locked')
res.data.data.cards.forEach(card=>{
card.text=card.name;
let subjectItem=subjectObj[card.subject]
if(subjectItem){
if(subjectItem.child){
subjectItem.child.push(card)
}else{
subjectItem.child=[card]
}
}
bindGetUserInfo (e) {
console.log(e.detail.userInfo)
},
getUserProfile(e) {
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res);
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
onChooseAvatar(e) {
const { avatarUrl } = e.detail
this.setData({
avatarUrl,
})
},
formatMenusData(res,scene){
// console.log(res.data.data.list)
let subjects=res.data.data.subjects;
let subjectObj={}
let subjectArr=subjects.forEach((i,idx)=>{
subjectObj[i]={
text:i,
key:idx
}
// card.pics=card.pics.map(i=>{
// return i.map(j=>{
// console.log(j)
// j.url=j.url.indexOf('http')>-1?j.url:"https:"+j.url
// return j
// })
// })
if(card.id===Number(scene)){
this.setData({
mainActiveIndex:subjectItem.key
})
}
card.disabled=no_locked?false:(!!card.is_locked)
// card.disabled=true;
})
this.setData({
menusArr:Object.values(subjectObj).sort((a,b)=>a.key-b.key),
cardData:res.data.data.cards,
activeSceneId:Number(scene),
curCardData:res.data.data.cards.filter(i=>Number(i.id)===Number(scene))[0]||{}
})
console.log(res.data.data.cards.filter(i=>Number(i.id)===Number(scene))[0]||{})
})
const no_locked = wx.getStorageSync('no_locked')
res.data.data.cards.forEach(card=>{
card.text=card.name;
let subjectItem=subjectObj[card.subject]
if(subjectItem){
if(subjectItem.child){
subjectItem.child.push(card)
}else{
subjectItem.child=[card]
}
}
if(card.id===Number(scene)){
this.setData({
mainActiveIndex:subjectItem.key
})
}
card.disabled=(res.data.data.has_buy_card||no_locked)?false:(!!card.is_locked)
// card.disabled=true;
})
this.setData({
menusArr:Object.values(subjectObj).sort((a,b)=>a.key-b.key),
cardData:res.data.data.cards,
activeSceneId:Number(scene),
curCardData:res.data.data.cards.filter(i=>Number(i.id)===Number(scene))[0]||{}
})
},
getToken(app_token,key='token'){
return new Promise((resolve,rej)=>{
request({
url:`/xcx/login/mobile_login`,
data:{
[key]:app_token,
},
method:"post",
success:(res)=>{
if(res.data&&res.data.code===0){
resolve(res.data.data.user_token);
}
}
})
})
},
getMenusData(){
return new Promise((resolve,rej)=>{
request({
url:"/xcx/wz/card_tree",
success:(res)=>{
console.log(res.data)
if(res.data&&res.data.code===0){
resolve(res)
}
}
})
})
},
onShowMenus(){
console.log(6)
this.setData({
......@@ -186,6 +240,11 @@ Page({
*/
onShow: function () {
// this.changeScrollHeight()
this.setData({
tooltipsImg:wx.getStorageSync("tooltipsImg")===false?false:true,
tooltipsMenus:wx.getStorageSync("tooltipsMenus")===false?false:true,
token:wx.getStorageSync("token")||''
})
},
changeScrollHeight(){
clearTimeout(this.timer)
......@@ -194,12 +253,14 @@ Page({
},4000)
},
closeTooltips(){
closeTooltips(e){
if(this.data.tooltipsImg||this.data.tooltipsMenus){
this.setData({
tooltipsImg:false,
tooltipsMenus:false
})
this.setStoreTooltipsImg();
this.setStoreTooltipsMenus();
}
},
/**
......@@ -346,6 +407,9 @@ Page({
wx.reportAnalytics('save_img', {
scene: this.data.scene,
});
wx.reportEvent('save_img', {
scene: this.data.scene,
});
let imgUrl=this.data.curCardData.full_pic.url;
wx.downloadFile({
url: imgUrl.indexOf('http')>-1?imgUrl:'https:'+imgUrl,
......@@ -381,5 +445,41 @@ Page({
this.setData({
menusShow:false
})
},
async getPhoneNumber (event) {
if(event.detail.code){
let tokenData = await this.getToken(event.detail.code,'code'); //拿app的token获取小程序的token;
wx.setStorageSync('xcx_token',tokenData)
this.setData({
xcx_token:tokenData
})
let resultData=await this.getMenusData();
if(resultData.has_buy_card){ //已购买则所有的锁都消失 并跳转到对应的卡片
let menusArr = this.data.menusArr.map(i=>{
i.child=i.child.map(j=>{
j.disabled=false
return j
})
return i;
})
this.setData({
menusArr
})
}else{ //未购买则弹出
// wx.showToast({
// icon:'none',
// title:'您暂时没有查看权限'
// })
}
// var item = event.currentTarget.dataset.item;
this.onSelectItem(event);
}
}
})
......@@ -15,18 +15,18 @@
class="width100 displayBlock"
/>
</view>
<text class="txt-end" id="end">- END -</text>
<!-- <text class="txt-end" id="end">- END -</text>-->
<view id="end-line" class="end-line"/>
<view class="docker-view {{!isBottom?'':'fixedbottom140'}}">
<view class="docker-view {{!isBottom?'':'fixedbottom160'}}">
<view class="icon-view " bindtap="gotoTop" wx:if="{{showTopBtn}}">
<van-icon name="arrow-up" size="60rpx" />
<van-icon size="60rpx" name="https://image.shenlancity.com/winterfell/static/20220530140805NNDWNQEW8GnK.png" />
</view>
<view class="icon-view" bindtap="onShowShare" >
<van-icon name="photo" size="60rpx"/>
<van-icon name="https://image.shenlancity.com/winterfell/static/20220530141106iLoDpFDKCjUf.png" size="60rpx"/>
</view>
<view wx:if="{{!isBottom}}">
<view class="icon-view" bindtap="onShowMenus">
<van-icon name="bars" size="60rpx"/>
<van-icon name="https://image.shenlancity.com/winterfell/static/20220530141152dnRNRRCjxxwg.png" size="60rpx"/>
</view>
</view>
......@@ -34,7 +34,7 @@
<text class="tooltips-img" wx:if="{{tooltipsImg}}">点击按钮可以将页面生成长图保存</text>
<text class="tooltips-menus" wx:if="{{tooltipsMenus}}">点击按钮可以查看更多大纲内容</text>
<van-button class="fixed-btn-menus" wx:if="{{isBottom}}" type="info" bindtap="onShowMenus"><van-icon name="bars" />查看完整2022新大纲</van-button>
<van-button class="fixed-btn-menus" wx:if="{{isBottom}}" type="info" bindtap="onShowMenus">查看完整 2022 新大纲</van-button>
<!-- <van-share-sheet-->
<!-- show="{{ showShare }}"-->
<!-- title=""-->
......@@ -69,12 +69,12 @@
<view class="share-columns">
<view class="share-item share-save" bindtap="onSelectShare">
<view class="icon-view" >
<van-icon name="photo" size="60rpx"/>
<van-icon name="https://image.shenlancity.com/winterfell/static/20220530141106iLoDpFDKCjUf.png" size="60rpx"/>
</view>
<text class="save-text">保存到本地</text>
</view>
</view>
<van-button class="width100 cancel-btn" bindtap="onCloseShare">取消</van-button>
<van-button custom-class="width100 cancel-btn" class="width100 cancel-btn" bind:click="onCloseShare">取消</van-button>
</view>
</van-overlay>
......@@ -107,6 +107,10 @@
data-item="{{ item }}"
bind:tap="onSelectItem"
>
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="phone"
wx:if="{{(!xcx_token)&&item.disabled}}"
data-item="{{ item }}"
>获取手机号</button>
{{ item.text }}
<van-icon
wx:if="{{ wxs.isActive(activeSceneId, item.id,item.disabled) }}"
......
/* pages/card/index.wxss */
page{
padding-bottom:100rpx;
background: #fff;
padding-bottom:148rpx;
}
.displayBlock{
display:block;
......@@ -15,8 +16,8 @@ page{
bottom:60rpx;
z-index:9;
}
.fixedbottom140{
bottom:140rpx;
.fixedbottom160{
bottom:160rpx;
}
.icon-view{
margin-top:20rpx;
......@@ -51,13 +52,16 @@ page{
position:fixed;
width:100%;
left:0;
bottom:20rpx;
margin-left:5%;
bottom:48rpx;
margin-left:6.4%;
font-weight: bold;
}
.fixed-btn-menus .van-button{
width:90%;
border-radius:44px;
width:87.2%;
height: 112rpx;
border-radius:112rpx;
font-size: 32rpx;
}
.tooltips-img,.tooltips-menus{
......@@ -119,11 +123,17 @@ page{
border-bottom:1rpx solid #ccc;
}
.cancel-btn{
display: block;
width:100%;
height:100rpx;
line-height:100rpx;
border:none;
}
.cancel-btn:active,.cancel-btn:focus,.cancel-btn:hover{
background: #fff;
}
.cancel-btn .van-button{
height:100rpx;
}
.share-item{
display:flex;
justify-content:center;
......@@ -194,6 +204,14 @@ page{
transform:translateX(-50%);
}
.phone{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
opacity: 0;
}
......@@ -246,3 +264,4 @@ page{
border-radius: 5px;
}
......@@ -14,7 +14,9 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(!wx.getStorageSync('xcx_token')) {
wx.setStorageSync('app_token', options.token || ''); //保存app的token,供登录的时候使用
}
},
/**
......
......@@ -12,7 +12,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.options=options;
},
/**
......@@ -64,8 +64,9 @@ Page({
},
gotoCard(){
wx.navigateTo({
url: '/pages/card/index?scene=1&from=index',
url: `/pages/card/index?scene=1&from=${this.options.from||'index'}&token=${this.options.token||wx.getStorageSync("app_token")||''}`,
})
}
})
......@@ -11,11 +11,14 @@ Page({
// url:'https://work.weixin.qq.com/gm/'+(query.gId||'')
url:query.gId
})
if(!wx.getStorageSync('xcx_token')) {
wx.setStorageSync('app_token', query.token || ''); //保存app的token,供登录的时候使用
}
},
startmessage:function(){
},
completemessage:function(){
}
})
......@@ -18,6 +18,10 @@ Page({
this.setData({
url: host+'/h5/app3/product/common?id='+(options.id||162)
})
if(!wx.getStorageSync('xcx_token')){
wx.setStorageSync('app_token',options.token||''); //保存app的token,供登录的时候使用
}
},
/**
......
// pages/a/index.wxm.js
const app = getApp()
import {request} from "../../utils/request.js"
Page({
/**
* 页面的初始数据
*/
data: {
url:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getUrl(options.id)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
onShareTimeline: function () {
},
getUrl:function(id){
request({
url:"/h5/api/group/study_group_info?ajax=1&id="+id,
success:(res)=>{
if(res.data&&res.data.code===0){
this.setData({
url:res.data.data.uniq_code,
})
}
}
})
},
})
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/a/index.wxm.wxml-->
<web-view src="{{url}}" ></web-view>
/* pages/a/index.wxm.wxss */
\ No newline at end of file
// externalLink.js
// 获取应用实例
const app = getApp()
// NOTE: 这里的域名请于管理后台-小程序设置-配置域名中配置的域名保持一致
const baseHost = "https://hrcpjcaabj.miniapp.weibanzhushou.com"
const baseWebViewUrl = `${baseHost}/H5/external_links_wx`
Page({
data: {
webViewUrl: ""
},
// 事件处理函数
async onLoad(pageParams) {
// 同步获取用户 login 后的 unionId
const { unionId } = await app.syncGetUnionId()
console.log(unionId)
// const unionId='o893uwiRhcxNdHfmx19GQW_W9MwM';
// 微伴会在通过小程序 urlscheme.generate 接口生成 scheme 码
// 时,将参数 c 和 hash_id 配置在 jump_wxa.query 中。
// externalLink 页面载入时,会被微信自动加入到页面参数中。
// 具体逻辑可查阅:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html
let { c, hash_id, debug } = pageParams
//hash_id='r7p1mtfei'
//c='X1FnUl5BRW0ABwIIWl5tUF1ERQ'
// 不建议对以下 webViewUrl 的拼接代码进行修改,以免遗漏参数
const webViewUrl = `${baseWebViewUrl}?hash_id=${hash_id || ''}&_c=${c || ''}&unionId=${unionId}`
if (!unionId && debug) {
wx.showModal({
title: '提示',
content: '参数错误:缺少 unionId',
})
}
if (debug) {
wx.showModal({
title: 'For debug',
content: webViewUrl
})
}
// 参数 c 和 hash_id 用于公司和引流链接配置的匹配
// 参数 unionId 用于引流链接的访问数据统计
this.setData({ webViewUrl })
// 显示分享按钮,贵司可按需调用
// this.showShareMenu()
},
showShareMenu() {
// 显示分享按钮的逻辑可查阅:https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.showShareMenu.html
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
})
}
})
{
"usingComponents": {}
}
\ No newline at end of file
<!--externalLink.wxml-->
<web-view src="{{webViewUrl}}"></web-view>
\ No newline at end of file
import {request} from "../../utils/request";
Page({
data: {
path: "",
picture_list:[]
},
onLoad(pageParams){
this.path=pageParams.yz_url;
this.loadImgs(pageParams.pic_id)
},
loadImgs(id){
if(!id){
return
}
request({
url:"/xcx/picture?ids="+id,
success:(res)=>{
console.log(res.data)
if(res.data&&res.data.code===0){
// console.log(res.data.data.list)
this.setData({
picture_list:Array.isArray(res.data.data)?res.data.data.reverse():[],
})
}
}
})
},
gotomini(){
wx.navigateToMiniProgram({
path:this.path,
appId:'wxb600f58eba6a3af9',
success(res){
console.log(res)
},
fail(err){
console.log(err)
},
complete(){
console.log('complete')
}
})
}
})
{
"usingComponents": {}
}
\ No newline at end of file
<view>
<view class="img_list">
<image
wx:for="{{picture_list}}"
wx:key="id"
src="{{item.url}}"
class="img_item"
style="height:{{item.height/item.width*750}}rpx"
></image>
</view>
<view class="join-btn" bindtap="gotomini">
<view class="join-btn-text">开始拼团</view>
</view>
</view>
page{
background: none;
}
.img_list{
width: 100%;
padding-bottom: 176rpx;
}
.img_item{
display: block;
width: 100%;
}
.join-btn{
position: fixed;
left:0;
bottom:0;
width: 100%;
height:176rpx;
line-height: 176rpx;
text-align: center;
color:#fff;
font-size: 30rpx;
font-weight: 600;
z-index: 5;
background: #fff;
}
.join-btn-text{
position: relative;
width:85%;
left:50%;
top:50%;
transform:translate(-50%,-50%);
height:110rpx;
line-height:110rpx;
border-radius:110rpx;
z-index: 1;
background: linear-gradient(180deg, rgba(245, 110, 81, 1) 0%, rgba(234, 62, 102, 1) 100%);
}
......@@ -66,7 +66,7 @@
{
"name": "pages/joinGroup/index",
"pathName": "pages/joinGroup/index",
"query": "gId=https://work.weixin.qq.com/gm/392681dd4ee5031d28f1136841fbd76e",
"query": "gId=https://work.weixin.qq.com/gm/392681dd4ee5031d28f1136841fbd76e&token=kKePWtxhLFLsATMy",
"scene": null
},
{
......@@ -96,13 +96,13 @@
{
"name": "pages/joinGroupH5/index",
"pathName": "pages/joinGroupH5/index",
"query": "id=29",
"query": "id=29&token=kKePWtxhLFLsATMy",
"scene": null
},
{
"name": "pages/card/index",
"pathName": "pages/card/index",
"query": "scene=2",
"query": "from=app&token=SmYS1b7hQx2VBUaN",
"scene": null
}
]
......
......@@ -2,8 +2,8 @@
// export const host='http://winterfell.ltm.dev.neoteched.com' //开发
//export const host='http://wf.alpha.neoteched.com' //测试环境wf
//export const host='http://lxlsk.dev.neoteched.com' //开发
// export const host='https://winterfell-alpha.neoteched.com' //测试
export const host='https://sk2.shenlancity.com' //线上
export const host='https://winterfell-alpha.neoteched.com' //测试
// export const host='https://sk2.shenlancity.com' //线上
export const request=({url,data,method,header,success,fail})=>{
if(!url){
......@@ -15,8 +15,9 @@ export const request=({url,data,method,header,success,fail})=>{
method: method||"GET",
header: header||{
'content-type': 'application/json',
'Authorization':wx.getStorageSync("xcx_token")||'',
},
// data:data||null,
data:data||null,
success: success||(res=>{
console.log("成功");
console.log(res);
......
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