Commit 9c62e414 by wangzhihui

Merge branch 'SAAS+V4.56.0-0908' of http://192.168.3.233:8090/saas/mini-program/…

…points-mall into SAAS+V4.56.0-0908
2 parents 32d514a8 aafbf6fe
import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let index = 2
let index = 1
/**
*
......
......@@ -36,27 +36,45 @@ module.exports = {
return http.getMock();
},
/**手机号验证码登录 */
phoneSmsLogin() {
phoneSmsLogin(data) {
return http.fetch('scrm.api.sso.sms.login', {
source: 'MINIAPP',
...data
})
},
/**微信授权手机号登录 */
authPhoneLogin() {
authPhoneLogin(data) {
return http.fetch('scrm.api.sso.weapp.auth.phone', {
source: 'MINIAPP',
...data
})
},
/**查询积分钱包开通状态 */
getPointsWalletStatus() {
/**获取积分渠道列表 */
getPointsSourceList(data) {
return http.fetch('scrm.api.shopmall.score.get.channelSource', {
...data
})
},
/**查询积分钱包 */
getPointsWalletData(data) {
return http.fetch('scrm.api.shopmall.pointswallet.get', {
...data
})
},
/**开通积分钱包 */
openPointsWallet() {
openPointsWallet(data) {
return http.fetch('scrm.api.shopmall.pointswallet.open', {...data})
},
/**替换积分钱包昵称 */
replaceWalletName(data) {
return http.fetch('scrm.api.sso.nickName.replace', {...data})
},
/**获取积分汇总数据 */
getPointsSummary(data) {
return http.fetch('scrm.api.shopmall.score.summary.search', {...data})
},
/**获取用户信息 */
getLoginInfo(data) {
return http.fetch('scrm.api.sso.weapp.loginfo.get', {...data})
}
};
......@@ -78,28 +78,20 @@ class Request {
},
data
} = response
if (returnAll) {
resolve(data)
return
}
if (code == 20 || code == 21) {
wx.p.storage.rm('userInfo')
wx.p.storage.rm('sessionId')
wx.p.storage.rm('channelSource')
wx.hideLoading()
const thisPage = wx.p.router.getPageInstance(),
options = Object.keys(thisPage.options)
let currentRoute = thisPage.route,
query = []
if (options.length) {
options.map(key => {
query.push(`${key}=${thisPage.options[key]}`)
})
}
if (query.length) currentRoute += `?${query.join('&')}`
return wx.p.router.redirectTo('/pages/loading/loading', {
url: `/${currentRoute}`
})
// session过期跳转到登录页
wx.p.router.reLaunch('/pages/Login/Login')
} else {
if (code == '0') {
if (returnAll) {
resolve(data)
} else {
resolve(data.data)
}
} else {
wx.showToast({
title: message || '系统异常',
......
......@@ -2,6 +2,7 @@
import {
centsToyuan
} from '~/utils/format'
import cartApi from '~/api/module/cart.js'
Component({
/**
* 组件的属性列表
......@@ -43,12 +44,14 @@ Component({
// 加入购物车
joinCart(e) {
let { target } = e.currentTarget.dataset
console.log('33333')
this.triggerEvent('join', target)
}
},
lifetimes: {
attached() {
this.setWidth()
let userInfo = wx.p.storage.get('userInfo')
this.setData({userInfo})
}
}
})
\ No newline at end of file
......@@ -2,6 +2,6 @@
"navigationStyle": "custom",
"usingComponents":{
"mp-html":"/components/mp-html/index",
"sku": "./components/Sku"
"sku": "/components/Sku"
}
}
\ No newline at end of file
import { commonApi } from '~/api/module/common'
import commonApi from '~/api/module/common.js'
const phoneRex = /^[1]([3-9])[0-9]{9}$/
Page({
/**
......@@ -18,7 +18,9 @@ Page({
}, {
text: '同意',
extClass: 'btn_primary'
}]
}],
pointsSource: [],
walletObj: {}
},
changeLoginType() {
const {
......@@ -48,7 +50,7 @@ Page({
data,
code
} = await wx.p.api.userApi.login()
if (code == '0') this.customerLoginCallBack(data)
// if (code == '0') this.customerLoginCallBack(data)
if (data) this.sessionId = data.sessionId
wx.hideLoading()
},
......@@ -139,7 +141,6 @@ Page({
if (!mobile) throw '请输入手机号'
if (!captcha) throw '请输入验证码'
if (!phoneRex.test(mobile)) throw '请输入正确的手机号'
// if (!isAgree) throw '请同意以下用户协议'
wx.p.wxApi.showLoading()
const {
code,
......@@ -164,57 +165,146 @@ Page({
async getPhoneNumber({
detail
}) {
const {
isAgree
} = this.data
try {
if (detail.errMsg && ['authorized', 'deny'].findIndex(e => detail.errMsg.toLowerCase().includes(e)) != -1) return
if (!detail?.code) throw '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
// if (!isAgree) throw '请同意以下用户协议'
wx.p.wxApi.showLoading()
let obj = {
encryptedData: detail.encryptedData,
iv: detail.iv,
sessionId: this.sessionId
}
const {
code,
data,
message
} = await commonApi.authPhoneLogin(detail, this.sessionId)
} = await commonApi.authPhoneLogin(obj)
wx.hideLoading()
if (code == '0') this.customerLoginCallBack(data)
else throw message
} catch (error) {
console.log(error, '222222')
this.showTips(error || '服务不可用')
setTimeout(() => {
this.onLoad()
}, 1500)
}
},
/**C端登录回调 */
/**登录回调 */
customerLoginCallBack(data) {
wx.p.storage.set('sessionId', data?.sessionId)
// 获取积分来源
this.getSource(data)
},
getSource(loginData) {
commonApi.getPointsSourceList({
staffPhone: loginData?.phone
}).then(res => {
let { code, data, message } = res
if (code == 0) {
this.setData({pointsSource: data?.map(val => { return val.channelSource })})
if (data?.length > 1) { // 积分渠道来源大于1 需要选择
this.setData({
showChooseSource: true
})
} else if (data?.length == 1) {
this.setChannelSource(data[0]?.channelSource, loginData)
}
} else {
wx.p.wxApi.showToast(message)
}
})
},
// 设置积分渠道
setChannelSource(source, loginData) {
wx.p.isLogin = true
wx.p.storage.set('userInfo', data)
wx.p.storage.set('sessionId', data.sessionId)
// 返回上一页
wx.p.router.back(thisPage => {
thisPage && thisPage.setData({
userInfo: data
wx.p.storage.set('userInfo', {...loginData})
wx.p.storage.set('channelSource', `${source}`)
wx.p.storage.set('sessionId', loginData?.sessionId)
// 查询积分钱包
this.getPointsWallet()
},
// 获取积分钱包数据
getPointsWallet() {
let userInfo = wx.p.cache.userInfo.getUserInfo()
commonApi.getPointsWalletData({
phone: userInfo?.phone,
name: userInfo?.nickName,
scoreSource: wx.p.storage.get('channelSource')
}).then(res => {
let { code, data, message } = res
if (code == 0) {
if (data && Object.keys(data)?.length) { // 有数据返回说明已开通钱包
// 调用替换钱包昵称接口
this.replaceNickName(data)
} else {
let channelSource = wx.p.storage.get('channelSource')
// 获取当前积分数量
commonApi.getPointsSummary({staffPhone: userInfo?.phone, channelSource}).then(r => {
if (r?.code == 0) {
this.setData({
showEnableWallet: true,
walletObj: {name: userInfo?.nickName, phone: userInfo?.phone, scoreSource: channelSource, currentScore: r?.data?.currentScore || 0}
})
thisPage.onLoginSuccess && thisPage.onLoginSuccess() //登陆成功后页面回调
} else {
wx.p.wxApi.showToast(r.message)
}
})
}
} else {
wx.p.wxApi.showToast(message)
}
})
},
// 选择积分来源
pointSourceEvent() {
// 替换积分钱包昵称
replaceNickName(data) {
let userInfo = wx.p.cache.userInfo.getUserInfo()
commonApi.replaceWalletName({
nickName: data?.name,
phone: data?.phone,
scoreSource: data?.scoreSource
}).then(res => {
let { code, data, message } = res
wx.p.storage.set('userInfo', {...userInfo, nickName: data?.name}) // 更新storage中的nickName
if (code == 0) {
wx.p.router.reLaunch('/pages/tab/index/index')
} else {
wx.p.wxApi.showToast(message)
}
})
},
// 选择积分来源
pointSourceEvent(e) {
wx.p.storage.set('channelSource', `${e.detail}`)
},
// 关闭开通积分钱包弹窗
closeWallet() {
this.setData({ showEnableWallet: false })
let userInfo = wx.p.cache.userInfo.getUserInfo()
let data = {
name: userInfo?.nickName,
phone: userInfo?.phone,
scoreSource: wx.p.storage.get('channelSource')
}
// 替换钱包昵称 使用登录信息返回的数据
this.replaceNickName(data)
},
// 一键开通积分钱包
enableWalletConfirm() {
enableWalletConfirm(e) {
let { walletObj } = e.detail
commonApi.openPointsWallet(walletObj).then(res => {
let { code, message } = res
if (code == 0) {
// 替换钱包昵称
this.replaceNickName({...walletObj})
} else {
wx.p.wxApi.showToast(message)
}
})
},
// 开通成功
......
......@@ -66,8 +66,8 @@
</view>
</Dialog>
<!-- 积分来源选择 -->
<points-source show="{{showChooseSource}}" bindconfirm="pointSourceEvent"></points-source>
<points-source show="{{showChooseSource}}" pointsSource="{{pointsSource}}" bindconfirm="pointSourceEvent"></points-source>
<!-- 开通钱包 -->
<enable-wallet show="{{showEnableWallet}}" bindclose="closeWallet" bindconfirm="enableWalletConfirm"></enable-wallet>
<enable-wallet show="{{showEnableWallet}}" walletObj="{{walletObj}}" bindclose="closeWallet" bindconfirm="enableWalletConfirm"></enable-wallet>
<!-- 钱包开通成功 -->
<enable-success show="{{showEnableSuccess}}" bindconfirm="successConfirm"></enable-success>
\ No newline at end of file
......@@ -7,6 +7,10 @@ Component({
properties: {
show: {
type: Boolean
},
walletObj: {
type: Object,
value: {}
}
},
......@@ -43,14 +47,15 @@ Component({
let { value } = e.detail
value = target == 'phone' ? value.replace(/[^0-9]/g, '') : value
this.setData({
[target]: value
[`walletObj.${target}`]: value
})
},
// 开通
confirm() {
let { name, phone } = this.data
if (!name) return wx.p.wxApi.showToast('姓名不能为空')
if (!phone || !/^[1]([3-9])[0-9]{9}$/.test(phone)) return wx.p.wxApi.showToast('请输入正确手机号')
let { walletObj } = this.data
if (!walletObj?.name) return wx.p.wxApi.showToast('姓名不能为空')
if (!walletObj?.phone || !/^[1]([3-9])[0-9]{9}$/.test(walletObj?.phone)) return wx.p.wxApi.showToast('请输入正确手机号')
this.triggerEvent('confirm', {walletObj})
}
}
})
\ No newline at end of file
......@@ -17,18 +17,18 @@
<view class="label">{{item.label}}</view>
<view class="tips">
{{item.tips}}
<text class="label" wx:if="{{item.pointsFlag}}">{{1500}}</text>
<text class="label" wx:if="{{item.pointsFlag}}">{{walletObj.currentScore}}</text>
</view>
</view>
</view>
<view class="text">请确认信息无误</view>
<view class="input-box">
<view class="input-label">姓名</view>
<input bindinput="input" data-target="name" maxlength="10" value="{{name}}" type="text" placeholder="请输入"/>
<input bindinput="input" data-target="name" maxlength="10" value="{{walletObj.name}}" type="text" placeholder="请输入"/>
</view>
<view class="input-box">
<view class="input-label">手机号</view>
<input bindinput="input" data-target="phone" maxlength="11" value="{{phone}}" type="text" placeholder="请输入"/>
<input bindinput="input" data-target="phone" maxlength="11" value="{{walletObj.phone}}" type="text" placeholder="请输入"/>
</view>
<view class="wallet-btn" bindtap="confirm">一键开通</view>
</view>
......
......@@ -7,6 +7,16 @@ Component({
properties: {
show: {
type: Boolean
},
pointsSource: {
type: Array,
observer: function(val) {
let { sourceArr } = this.data
const filteredArr = sourceArr.filter(item => val?.includes(Number(item.id)))
this.setData({
channelSourceArr: filteredArr
})
}
}
},
......@@ -14,25 +24,26 @@ Component({
* 组件的初始数据
*/
data: {
sourceArr: [{
sourceArr: [ {
id: 1,
label: '续保用户',
color: '#AF531F',
background: 'linear-gradient(90deg, #FCF5E5 0%, #FFE9BD 100%)',
icon: 'source-1'
}, {
id: 2,
label: '阳光激励用户',
color: '#C7462B',
background: 'linear-gradient(90deg, #FCF3F2 0%, #FFE0DB 100%)',
icon: 'source-2'
}, {
id: 2,
label: '续保用户',
color: '#AF531F',
background: 'linear-gradient(90deg, #FCF5E5 0%, #FFE9BD 100%)',
icon: 'source-1'
}, {
id: 3,
label: '管理层',
color: '#244BCA',
background: 'linear-gradient(90deg, #E7F5FD 0%, #C3E7FF 100%)',
icon: 'source-3'
}]
}],
channelSourceArr: []
},
/**
......@@ -42,21 +53,22 @@ Component({
// 切换选择来源
checkSource(e) {
let { target } = e.currentTarget.dataset
let { sourceArr } = this.data
sourceArr?.forEach(val => {
let { channelSourceArr } = this.data
channelSourceArr?.forEach(val => {
val.isChecked = false
if (val.id == target.id) {
val.isChecked = true
}
})
this.setData({sourceArr})
this.setData({channelSourceArr})
},
// 下一步
nextStep(e) {
let { target } = e.currentTarget.dataset
if (target) return // 未选择来源不可点击
// 请求接口
console.log('请求接口')
let { channelSourceArr } = this.data
let channelSource = channelSourceArr?.find(val => val.isChecked == true)?.id
this.triggerEvent('confirm', channelSource)
}
}
})
\ No newline at end of file
......@@ -16,7 +16,7 @@
<view class="source-content isFullSucreen {{close?'close':''}}">
<view class="title">您的积分渠道来源</view>
<view class="source-box">
<view class="source-item" wx:for="{{sourceArr}}" wx:key="index" bindtap="checkSource" data-target="{{item}}" style="color: {{item.color}};background-image: {{item.background}};">
<view class="source-item" wx:for="{{channelSourceArr}}" wx:key="index" bindtap="checkSource" data-target="{{item}}" style="color: {{item.color}};background-image: {{item.background}};">
<view>
<view class="source-icon">
<glsx-image src="/login/{{item.icon}}.png"></glsx-image>
......@@ -28,6 +28,6 @@
</view>
</view>
</view>
<view class="btn {{fn.btnDisabled(sourceArr) ? 'disabled' : ''}}" bindtap="nextStep" data-target="{{fn.btnDisabled(sourceArr)}}">下一步</view>
<view class="btn {{fn.btnDisabled(channelSourceArr) ? 'disabled' : ''}}" bindtap="nextStep" data-target="{{fn.btnDisabled(channelSourceArr)}}">下一步</view>
</view>
</view>
\ No newline at end of file
// pages/loading/loading.js
import { systemApi } from "~/api/index";
import commonApi from '~/api/module/common.js'
Page({
/**
* 页面的初始数据
......@@ -24,23 +25,16 @@ Page({
this.login();
},
async login(options = {}) {
if (options.merchantId) wx.$merchant_id = options.merchantId;
try {
const { code, data, message } = await wx.p.api.userApi.login();
if (data)
wx.p.storage.set("merchant_info", {
merchantId: data.merchantId,
merchantName: data.merchantName,
});
const { code, data, message } = await commonApi.getLoginInfo();
if (code == "0") {
wx.p.isLogin = true;
wx.p.storage.set("userInfo", data);
wx.p.storage.set("sessionId", data.sessionId);
if (!data) throw message;
wx.p.storage.set("userInfo", data)
if (!data) throw message
} else {
wx.p.isLogin = false;
wx.p.storage.rm("userInfo");
wx.p.storage.rm("sessionId");
wx.p.storage.rm("channelSource")
}
console.log("登陆信息:", data);
if (options.url) {
......
......@@ -27,17 +27,8 @@
background: #FFFFFF;
}
.type-1 .button {
width: 104rpx;
height: 60rpx;
border-radius: 38rpx;
background-color: var(--btnColor);
color: #fff;
font-size: var(--margin);
}
.type-1 .input-box {
width: calc(100% - 110rpx);
width: 100%;
display: flex;
align-items: center;
}
......
......@@ -42,27 +42,21 @@ Component({
methods: {
handleFixedTabChange(e) {
let { value } = e.currentTarget.dataset
let { activeSubTab } = this.data
this.setData({
activeTab: value,
to: `to-${value}`
})
this.triggerEvent('tabchange', { activeTab: value, activeSubTab })
},
handleDynamicTabChange(e) {
let { value } = e.currentTarget.dataset
let { activeTab } = this.data
this.setData({
activeSubTab: value,
subTo: `to-${value}`
})
},
click(e) {
let {
count
} = e.currentTarget.dataset
this.setData({
count,
to: `to-${count}`
})
this.triggerEvent('click', count)
this.triggerEvent('tabchange', { activeTab, activeSubTab: value })
}
}
})
......
import {
kfMixin,
} from '~/mixins/index'
import homeApi from '~/api/module/home.js'
import commonApi from '~/api/module/common.js'
Page({
behaviors: [kfMixin],
/**
* 页面的初始数据
*/
......@@ -12,6 +10,7 @@ Page({
customerlist: [],
navStyle : "background-color: transparent;",
animationData: {},
bannerUrl: '',
specialSaleArr: [{
id: 1,
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/index/index-bg.png',
......@@ -129,6 +128,24 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const userInfo = wx.p.cache.userInfo.getUserInfo()
let channelSource = wx.p.storage.get('channelSource')
this.setData({userInfo, channelSource})
// 获取当前积分数据
this.getPointsData()
},
getPointsData() {
let { userInfo, channelSource } = this.data
if (!userInfo?.phone && !channelSource) return
commonApi.getPointsSummary({staffPhone: userInfo?.phone, channelSource: Number(channelSource)}).then(r => {
if (r?.code == 0) {
this.setData({
currentScore: r?.data?.currentScore || 0
})
} else {
wx.p.wxApi.showToast(r.message)
}
})
},
// 跳转积分中心
handleToPointCenter() {
......@@ -152,6 +169,19 @@ Page({
toIntegral(){
wx.p.router.go('/packageIndex/pages/integral/index/index')
},
// 商品搜素
handleSearch(e) {
console.log(e)
},
// 切换分类筛选
changeTab(e) {
console.log(e, '===')
},
// 加入购物车
handleAddToCart(e) {
},
/**
* 生命周期函数--监听页面显示
*/
......
......@@ -13,8 +13,6 @@ page {
.bg {
width: 100%;
height: 480rpx;
background: url('https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/index/index-bg.png') no-repeat;
background-size: 100% 480rpx;
position: fixed;
left: 0;
top: 0;
......
<navigation-bar page-title="积分商城" custom navStyle="{{navStyle}}">
<view class="page-title">积分商城</view>
</navigation-bar>
<view class="bg"></view>
<view class="bg">
<glsx-image src="{{bannerUrl || 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/index/index-bg.png'}}"></glsx-image>
</view>
<block wx:if="{{navHeight}}">
<view class="container-box">
<view class="container" style="height: calc(100vh - {{navHeight}}px);margin-top: {{navHeight}}px;">
<view class="points-box">
<view class="points-btn" bindtap="handleToPointCenter">
<view>
<view style="display: flex;align-items: center;">
<view class="icon">
<glsx-image src="/index/points-icon.png"></glsx-image>
</view>
<view class="points-num" bind:tap="toIntegral">1680</view>
<view class="points-num" bind:tap="toIntegral">{{currentScore || '-'}}</view>
</view>
<view class="arrow-icon">
<mp-icon icon="arrow" color="#F4776D" size="7"></mp-icon>
......@@ -41,11 +43,11 @@
<view class="goods-content">
<view class="goods-box-title">商品兑换</view>
<view class="sticky">
<search-box placeholder="搜索商品"></search-box>
<good-tab tab="{{tab}}" subTab="{{subTab}}" align="left" openScroll bindclick="changeTab" index="{{goodsIndex}}"></good-tab>
<search-box placeholder="搜索商品" bindsearch="handleSearch"></search-box>
<good-tab tab="{{tab}}" subTab="{{subTab}}" align="left" openScroll bindtabchange="changeTab" index="{{goodsIndex}}"></good-tab>
</view>
<view class="goods-box">
<goods list="{{goodsList}}"></goods>
<goods list="{{goodsList}}" bindjoin="handleAddToCart"></goods>
</view>
</view>
</block>
......@@ -53,5 +55,4 @@
</view>
</view>
</block>
<glsx-privacy appletName="积分商城"></glsx-privacy>
\ No newline at end of file
......@@ -12,6 +12,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let userInfo = wx.p.storage.get('userInfo')
this.setData({userInfo})
// this.getMemberCardData();
},
navbarReady(e) {
......
......@@ -11,7 +11,8 @@ export const STORAGE_OBJECTkEY = {
sessionId: 'sessionId',
bindInfo:'bindInfo',
unauthorized:'unauthorized',
wx_user_info:'wx_user_info'
wx_user_info:'wx_user_info',
channelSource: 'channelSource'
}
export default{
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!