Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高淑倩
7-Eleven
Commits
2f4fb0ba
Commit
2f4fb0ba
authored
Sep 05, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车立即购买授权
parent
5d6e0ed2
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
152 additions
and
93 deletions
+152
-93
bottomTabs.js
src/component/bottomTabs/bottomTabs.js
+1
-50
handlerData.wxs
src/component/bottomTabs/handlerData.wxs
+0
-2
skuPopup.js
src/component/skuPopup/skuPopup.js
+8
-0
skuPopup.wxml
src/component/skuPopup/skuPopup.wxml
+50
-10
my.js
src/pages/my/my.js
+0
-1
my.js
src/pages/my_11/my.js
+0
-3
productDetail.js
src/pages/productDetail/productDetail.js
+2
-1
productDetail.wxml
src/pages/productDetail/productDetail.wxml
+2
-0
userCenter.js
src/pages/userCenter/userCenter.js
+1
-1
userCenter.wxml
src/pages/userCenter/userCenter.wxml
+1
-1
util.js
src/utils/util.js
+71
-16
wxService.js
src/utils/wxService.js
+16
-7
utils.wxs
src/wxs/utils.wxs
+0
-1
No files found.
src/component/bottomTabs/bottomTabs.js
View file @
2f4fb0ba
...
...
@@ -46,56 +46,7 @@ Component({
*/
methods
:
{
_getUserInfo
(
res
=
{})
{
const
userInfo
=
res
.
detail
||
{}
console
.
log
(
'userInfo'
,
userInfo
)
// 先授权再领卡
if
(
res
.
detail
.
userInfo
)
{
utils
.
getUserInfoByBtn
(
userInfo
).
then
(
(
data
=
{}
)
=>
{
const
{
token
}
=
data
wx
.
setStorageSync
(
'_accreditUserInfo'
,
userInfo
)
wx
.
hideNavigationBarLoading
()
if
(
token
)
{
wx
.
setStorageSync
(
'token'
,
token
)
}
else
{
wx
.
setStorageSync
(
'token'
,
''
)
}
wx
.
setStorageSync
(
'_baseUserInfo'
,
data
)
// 缓存用户信息
this
.
setUserInfo
()
// 判断有无开卡
}).
catch
(
err
=>
{
if
(
err
)
{
wx
.
showToast
({
title
:
`会员系统异常请稍后重试!`
,
icon
:
'none'
})
}
})
}
},
setUserInfo
()
{
const
userInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
// 新用户去激活领卡
if
(
userInfo
&&
userInfo
.
member
&&
!
userInfo
.
member
.
mobile
)
{
console
.
log
(
'去开'
)
wxService
.
openCard
()
return
false
}
else
{
console
.
log
(
'已开'
)
}
// 跳转
const
urls
=
getCurrentPages
()
setTimeout
(()
=>
{
const
item
=
urls
[
0
].
options
if
(
item
.
route
)
{
try
{
const
options
=
JSON
.
parse
(
item
.
options
)
wxService
.
router
(
`/
${
item
.
route
}
`
).
search
(
options
).
replace
()
}
catch
(
e
)
{
wxService
.
router
(
'/pages/userCenter/userCenter'
).
replace
()
}
}
else
{
wxService
.
router
(
'/pages/userCenter/userCenter'
).
replace
()
}
},
200
)
this
.
triggerEvent
(
'getAuth'
,
res
);
},
handelToPage
(
event
){
const
ev
=
event
.
currentTarget
.
dataset
;
...
...
src/component/bottomTabs/handlerData.wxs
View file @
2f4fb0ba
function hanlerLinkNeedAuth(link){
console.log('linkwwwwwwwwwww', link)
var flag = false
if(link.indexOf('pages/my/my') > -1 || link.indexOf('pages/cart/cart') > -1 ){
flag = true
}
console.log('flag', flag)
return flag
}
...
...
src/component/skuPopup/skuPopup.js
View file @
2f4fb0ba
// component/skuPopup/skuPopup.js
// import { ReportModel } from '../../utils/reportModel'
const
wxService
=
require
(
'../../utils/wxService'
)
Component
({
/**
* 组件的属性列表
*/
properties
:
{
currentHasUserInfo
:{
type
:
Boolean
,
type
:
false
},
disableNum
:
{
// 不能改变的数量
type
:
Number
,
observer
:
'_disableNumChange'
,
...
...
@@ -373,6 +378,9 @@ Component({
// }
this
.
setData
(
updateData
)
console
.
log
(
'666'
,
updateData
.
skuStock
)
},
_getUserInfo
(
res
=
{})
{
this
.
triggerEvent
(
'getAuth'
,
res
);
}
}
})
src/component/skuPopup/skuPopup.wxml
View file @
2f4fb0ba
<!--component/skuPopup/skuPopup.wxml-->
<view class="popup-container{{show ? ' active' : ''}}" bindtap="hidePopup"
></view
>
<view class="popup-container{{show ? ' active' : ''}}" bindtap="hidePopup"
/
>
<view class="popup-content{{show ? ' active' : ''}}">
<image class="popup-close" mode="widthFix" src="/images/close.png" bindtap="hidePopup"></image>
<image
class="popup-close"
mode="widthFix"
src="/images/close.png"
bindtap="hidePopup"
/>
<view class="top-info clearfix">
<image mode="widthFix" src="{{curSku.sku_pic_url && curSku.sku_pic_url != 'undefined' ? (imageDomain + curSku.sku_pic_url) : indexImg}}"></image
>
<image mode="widthFix" src="{{curSku.sku_pic_url && curSku.sku_pic_url != 'undefined' ? (imageDomain + curSku.sku_pic_url) : indexImg}}" /
>
<view class="top-text">
<!-- <view class="price-text" wx:if="{{exchangePrice <= 0}}">¥{{price / 100}}</view> -->
<view class="price-text">¥{{salePrice}}</view>
<view class="stock-text">库存:{{skuStock}}</view>
<view class="sku-text">规格:<block wx:for="{{skuText}}" wx:key="{{index}}">{{item}} </block></view>
<view class="sku-text">规格:
<block wx:for="{{skuText}}" wx:key="{{index}}">{{item}} </block>
</view>
</view>
</view>
<!-- isAllowArrive 0 开启/放开 1 关闭/禁用 -->
<scroll-view class="mid-info" scroll-y="true">
<view class="sku-info" wx:for="{{specItem}}" wx:for-index="i" wx:key="{{i}}">
<view
class="sku-info"
wx:for="{{specItem}}"
wx:for-index="i"
wx:key="{{i}}"
>
<view class="spec-name">{{item.name}}</view>
<view class="spec-values" wx:for="{{item.sonList}}" wx:for-index="j" wx:key="{{j}}" wx:for-item="specValue">
<view class="spec-value {{specValue.stock == 0 ? ' disabled' : ''}}{{curSpec[i].name == specValue.name ? ' active' : ''}}" bindtap="selectSku" data-id="{{specValue.id}}" data-index="{{i}}" data-name="{{specValue.name}}" data-type="{{goodType}}" data-disable="{{specValue.skuStock == 0 ? true : false}}" data-stock="{{skuStock}}">{{specValue.name}}</view>
<view
class="spec-values"
wx:for="{{item.sonList}}"
wx:for-index="j"
wx:key="{{j}}"
wx:for-item="specValue"
>
<view
class="spec-value {{specValue.stock == 0 ? ' disabled' : ''}}{{curSpec[i].name == specValue.name ? ' active' : ''}}"
bindtap="selectSku"
data-id="{{specValue.id}}"
data-index="{{i}}"
data-name="{{specValue.name}}"
data-type="{{goodType}}"
data-disable="{{specValue.skuStock == 0 ? true : false}}"
data-stock="{{skuStock}}"
>{{specValue.name}}
</view>
<!-- <view wx:if="{{isAllowArrive}}" class="spec-value{{specValue.skuStock == 0 ? ' disabled' : ''}}{{curSpec[i] == specValue.skuName ? ' active' : ''}}" wx:for="{{specInfo.specValue}}" wx:for-index="j" wx:key="{{j}}" wx:for-item="specValue" data-stock="{{specValue.skuStock}}" data-name="{{specValue.skuName}}" data-index="{{i}}" data-type="{{goodType}}" data-disable="{{specValue.skuStock == 0 ? true : false}}" bindtap="selectSku">{{specValue.skuName}}</view> -->
<!-- <view wx:if="{{!isAllowArrive}}" class="spec-value{{specValue.skuStock == 0 ? ' disabled' : ''}}{{curSpec[i] == specValue.skuName ? ' active' : ''}}" wx:for="{{specInfo.specValue}}" wx:for-index="j" wx:key="{{j}}" wx:for-item="specValue" data-stock="{{specValue.skuStock}}" data-name="{{specValue.skuName}}" data-index="{{i}}" data-type="{{goodType}}" data-disable="{{specValue.skuStock == 0 && goodType == 2 ? true : false}}" bindtap="selectSku">{{specValue.skuName}}</view> -->
...
...
@@ -35,13 +63,25 @@
<view class="spec-name">数量</view>
<view class="num-panel">
<button bindtap="minusNum">-</button>
<input value="{{proNum}}" type="number" bindblur="inputNum"></input
>
<input value="{{proNum}}" type="number" bindblur="inputNum" /
>
<button bindtap="addNum">+</button>
</view>
</view>
</scroll-view>
<!-- 按钮状态 -->
<view wx:if="{{!currentHasUserInfo}}">
<button
bindgetuserinfo="_getUserInfo"
data-jflag="false"
open-type='getUserInfo'
class="confirm-button {{isOutStock? 'out-stock': ''}}"
hover-class="btn-hover"
>
{{btnText}}
</button>
</view>
<view wx:else>
<button class="confirm-button {{isOutStock? 'out-stock': ''}}" bindtap="confirm">{{btnText}}</button>
</view>
</view>
src/pages/my/my.js
View file @
2f4fb0ba
...
...
@@ -237,7 +237,6 @@ wxService.page({
if
(
res
&&
res
.
tentacleId
)
{
let
tentacleId
=
Integer
.
digit
(
res
.
tentacleId
,
10
,
64
);
var
path
=
`pages/userCenter/userCenter?t=
${
tentacleId
}
`
;
console
.
log
(
path
)
return
{
path
:
path
}
...
...
src/pages/my_11/my.js
View file @
2f4fb0ba
...
...
@@ -81,7 +81,6 @@ wxService.page({
}
},
touchM
:
function
(
e
)
{
console
.
log
(
'333'
,
e
)
if
(
e
.
touches
.
length
==
1
)
{
//手指移动时y方向位置
var
moveY
=
e
.
touches
[
0
].
clientY
;
...
...
@@ -90,12 +89,10 @@ wxService.page({
var
delBtnWidth
=
this
.
data
.
delBtnWidth
;
var
moveDistance
=
delBtnWidth
-
disY
;
var
txtStyle
=
""
;
console
.
log
(
'------'
,
disY
)
if
(
disY
==
0
||
disY
<
0
)
{
//如果移动距离小于等于0,文本层位置不变
txtStyle
=
"margin-top:-"
+
delBtnWidth
;
}
else
if
(
disY
>
0
)
{
//移动距离大于0,文本层left值等于手指移动距离
txtStyle
=
"margin-top:-"
+
moveDistance
+
"px"
;
console
.
log
(
'+++'
,
txtStyle
)
if
(
disY
>=
delBtnWidth
)
{
//控制手指移动距离最大值为删除按钮的宽度
txtStyle
=
"margin-top:0px"
;
...
...
src/pages/productDetail/productDetail.js
View file @
2f4fb0ba
...
...
@@ -2,7 +2,7 @@
var
app
=
getApp
()
const
wxService
=
require
(
'../../utils/wxService'
)
import
{
Integer
}
from
'../../utils/integerDigitalConvertion'
const
utils
=
require
(
'../../utils/util'
)
wxService
.
page
({
/**
...
...
@@ -103,6 +103,7 @@ wxService.page({
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
console
.
log
(
'0this.data.currentHasUserInfo'
,
this
.
data
.
currentHasUserInfo
)
this
.
getProInfo
()
this
.
getOpenStatus
()
this
.
data
.
currentShareContent
=
null
...
...
src/pages/productDetail/productDetail.wxml
View file @
2f4fb0ba
...
...
@@ -156,6 +156,8 @@
bind:skuselect="confirmClick"
btn-text="{{btnText}}"
product-stock="{{productInfo.stock}}"
currentHasUserInfo="{{currentHasUserInfo}}"
bind:getAuth="_getUserInfo"
/>
<card-modal
...
...
src/pages/userCenter/userCenter.js
View file @
2f4fb0ba
...
...
@@ -75,7 +75,7 @@ wxService.page({
* 生命周期函数--监听页面显示
*/
onShow
()
{
console
.
log
(
'0this.data.currentHasUserInfo'
,
this
.
data
.
currentHasUserInfo
)
// 取会员卡号
const
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
const
cardMember
=
wx
.
getStorageSync
(
'_cardMember'
)
...
...
src/pages/userCenter/userCenter.wxml
View file @
2f4fb0ba
...
...
@@ -15,7 +15,7 @@
<bottom bottom="{{pItem.bottom}}" />
</view>
<view class="" wx:if="{{pItem.type == 5}}">
<bottom-tabs currHomePageId="{{currHomePageId}}" currentHasUserInfo="{{currentHasUserInfo}}" tab-bar="{{pItem.tabBar}}" bind:updatePage="updatePage"/>
<bottom-tabs currHomePageId="{{currHomePageId}}"
bind:getAuth="_getUserInfo"
currentHasUserInfo="{{currentHasUserInfo}}" tab-bar="{{pItem.tabBar}}" bind:updatePage="updatePage"/>
</view>
<view class="" wx:if="{{pItem.type == 6}}">
<announcement notice="{{pItem.notice}}" />
...
...
src/utils/util.js
View file @
2f4fb0ba
...
...
@@ -29,9 +29,9 @@ function getCurrentPageUrlWithArgs() {
var
url
=
currentPage
.
route
// 当前页面url
var
options
=
currentPage
.
options
// 如果要获取url中所带的参数可以查看options
/**
/**
* 拼接url的参数
*/
*/
var
urlWithArgs
=
url
+
'?'
for
(
var
key
in
options
)
{
var
value
=
options
[
key
]
...
...
@@ -56,21 +56,21 @@ function imageUtil(e) {
var
imageSize
=
{};
var
originalWidth
=
e
.
detail
.
width
;
//图片原始宽
var
originalHeight
=
e
.
detail
.
height
;
//图片原始高
var
originalScale
=
originalHeight
/
originalWidth
;
//图片高宽比
var
originalScale
=
originalHeight
/
originalWidth
;
//图片高宽比
//获取屏幕宽高
wx
.
getSystemInfo
({
success
:
function
(
res
)
{
// var windowWidth = res.windowWidth/2;
// var windowHeight = res.windowHeight/2;
// var windowWidth = (res.windowWidth - 30)/2;
var
windowWidth
=
(
res
.
windowWidth
-
15
)
/
2
;
var
windowHeight
=
res
.
windowHeight
/
2
;
var
windowscale
=
windowHeight
/
windowWidth
;
//屏幕高宽比
if
(
originalScale
<
windowscale
)
{
//图片高宽比小于屏幕高宽比
var
windowWidth
=
(
res
.
windowWidth
-
15
)
/
2
;
var
windowHeight
=
res
.
windowHeight
/
2
;
var
windowscale
=
windowHeight
/
windowWidth
;
//屏幕高宽比
if
(
originalScale
<
windowscale
)
{
//图片高宽比小于屏幕高宽比
//图片缩放后的宽为屏幕宽
imageSize
.
imageWidth
=
windowWidth
;
imageSize
.
imageHeight
=
(
windowWidth
*
originalHeight
)
/
originalWidth
;
}
else
{
//图片高宽比大于屏幕高宽比
}
else
{
//图片高宽比大于屏幕高宽比
//图片缩放后的高为屏幕高
// imageSize.imageHeight = windowHeight;
// imageSize.imageWidth = (windowHeight * originalWidth) / originalHeight;
...
...
@@ -80,7 +80,7 @@ function imageUtil(e) {
}
})
return
imageSize
;
}
}
/**
* 判断用户滑动
...
...
@@ -99,12 +99,12 @@ function getTouchData(endX, endY, startX, startY) {
/**
* view宽高比
*/
function
aspectRatio
(
h
,
w
)
{
function
aspectRatio
(
h
,
w
)
{
let
viewStyle
=
{}
let
originalScale
=
h
/
w
wxService
.
getSystemInfo
().
then
(
res
=>
{
let
windowscale
=
res
.
windowHeight
/
res
.
windowWidth
if
(
originalScale
<
windowscale
)
{
let
originalScale
=
h
/
w
wxService
.
getSystemInfo
().
then
(
res
=>
{
let
windowscale
=
res
.
windowHeight
/
res
.
windowWidth
if
(
originalScale
<
windowscale
)
{
viewStyle
.
width
=
res
.
windowWidth
viewStyle
.
height
=
(
res
.
windowWidth
*
h
)
/
w
;
}
else
{
...
...
@@ -118,11 +118,11 @@ function aspectRatio(h,w) {
/**
* 解析 url 参数
*/
function
parseUrl
(
query
){
function
parseUrl
(
query
)
{
var
result
=
[];
// var query = url.split("?")[1];
var
queryArr
=
query
.
split
(
"&"
);
queryArr
.
forEach
(
function
(
item
)
{
queryArr
.
forEach
(
function
(
item
)
{
var
obj
=
{};
var
value
=
item
.
split
(
"="
)[
0
];
var
key
=
item
.
split
(
"="
)[
1
];
...
...
@@ -284,7 +284,62 @@ const formatNumber = n => {
return
n
[
1
]
?
n
:
'0'
+
n
}
function
_getUserInfo
(
ev
)
{
console
.
log
(
'iiiiiiiiiiiiii'
,
ev
)
const
userInfo
=
ev
.
detail
return
getUserInfoByBtn
(
userInfo
).
then
((
data
=
{})
=>
{
const
{
token
}
=
data
wx
.
setStorageSync
(
'_accreditUserInfo'
,
userInfo
)
wx
.
hideNavigationBarLoading
()
if
(
token
)
{
wx
.
setStorageSync
(
'token'
,
token
)
}
else
{
wx
.
setStorageSync
(
'token'
,
''
)
}
wx
.
setStorageSync
(
'_baseUserInfo'
,
data
)
// 缓存用户信息
setUserInfo
()
// 判断有无开卡
}).
catch
(
err
=>
{
if
(
err
)
{
wx
.
showToast
({
title
:
`会员系统异常请稍后重试!`
,
icon
:
'none'
})
}
})
}
function
setUserInfo
()
{
const
userInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
// 新用户去激活领卡
if
(
userInfo
&&
userInfo
.
member
&&
!
userInfo
.
member
.
mobile
)
{
console
.
log
(
'去开'
)
wxService
.
openCard
()
return
false
}
else
{
console
.
log
(
'已开'
)
}
// 跳转
const
urls
=
getCurrentPages
()
setTimeout
(()
=>
{
const
item
=
urls
[
0
].
options
const
route
=
urls
[
0
].
route
console
.
log
(
'----------item'
,
route
,
item
)
if
(
route
)
{
try
{
const
options
=
item
wxService
.
router
(
`/
${
route
}
`
).
search
(
options
).
replace
()
}
catch
(
e
)
{
wxService
.
router
(
'/pages/userCenter/userCenter'
).
replace
()
}
}
else
{
wxService
.
router
(
'/pages/userCenter/userCenter'
).
replace
()
}
},
200
)
}
wxService
.
setGetAuthUserInfo
(
_getUserInfo
);
module
.
exports
=
{
_getUserInfo
,
formatTime
,
getCurrentPageUrl
,
getCurrentRouter
,
...
...
src/utils/wxService.js
View file @
2f4fb0ba
...
...
@@ -20,6 +20,7 @@ const citysData = require('./city.js')
import
{
Integer
}
from
'./integerDigitalConvertion'
let
openCardLister
=
null
/**
* 单例
*/
...
...
@@ -29,11 +30,15 @@ class WXService extends Http {
super
()
this
.
Promise
=
Promise
this
.
currentPage
=
null
this
.
getAuthUserInfo
=
null
}
getToken
()
{
return
super
.
getToken
()
}
setGetAuthUserInfo
(
getAuthUserInfo
)
{
this
.
getAuthUserInfo
=
getAuthUserInfo
;
}
/**
* 所有接口中返回401就登录
...
...
@@ -281,7 +286,7 @@ class WXService extends Http {
wx
.
setStorageSync
(
'TENTACLE_CONTENT'
,
storageObj
)
wx
.
setStorageSync
(
'TIME_EXPIRATION'
,
expiration
)
}
else
{
else
{
wx
.
removeStorageSync
(
'TENTACLE_CONTENT'
)
wx
.
removeStorageSync
(
'TIME_EXPIRATION'
)
}
...
...
@@ -290,22 +295,22 @@ class WXService extends Http {
})
}
//根据页面类型判断content取值
getContentByContentType
(
item
){
getContentByContentType
(
item
)
{
//1,2,3,8,9,10,11 页面 取页面标题
if
(
item
.
contentType
==
1
||
item
.
contentType
==
2
||
item
.
contentType
==
3
||
item
.
contentType
==
8
||
item
.
contentType
==
9
||
item
.
contentType
==
10
||
item
.
contentType
==
11
)
{
if
(
item
.
contentType
==
1
||
item
.
contentType
==
2
||
item
.
contentType
==
3
||
item
.
contentType
==
8
||
item
.
contentType
==
9
||
item
.
contentType
==
10
||
item
.
contentType
==
11
)
{
item
.
content
=
item
.
content
}
// 详情
if
(
item
.
contentType
==
4
||
item
.
contentType
==
6
)
{
if
(
item
.
contentType
==
4
||
item
.
contentType
==
6
)
{
let
content
=
JSON
.
parse
(
item
.
content
)
item
.
contentArr
=
[
content
]
}
// 内容列表
if
(
item
.
contentType
==
5
){
if
(
item
.
contentId
){
if
(
item
.
contentType
==
5
)
{
if
(
item
.
contentId
)
{
let
content
=
JSON
.
parse
(
item
.
content
)
item
.
contentArr
=
[
content
]
}
else
{
}
else
{
item
.
content
=
item
.
content
}
}
...
...
@@ -628,6 +633,10 @@ class WXService extends Http {
console
.
error
(
e
)
}
}
},
//统一处理用户授权获取用户信息回调
_getUserInfo
(
res
)
{
_self
.
getAuthUserInfo
(
res
.
detail
)
}
}
Page
(
Object
.
assign
({},
config
,
CONFIG_PAPGE
))
...
...
src/wxs/utils.wxs
View file @
2f4fb0ba
function date(time,format){
var date = getDate(time);
// console.log(date);
return date.getFullYear() + '-' + date.getMonth() + 1 + '-'+ date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' +date.getSeconds();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment