Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
junlebao-milk-20240619
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
junlebao-milk-20240619
Commits
ea23f1e7
Commit
ea23f1e7
authored
Jun 25, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
79085a3a
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
221 additions
and
71 deletions
+221
-71
app.ts
miniprogram/app.ts
+17
-14
index.less
miniprogram/pages/index/index.less
+11
-0
index.ts
miniprogram/pages/index/index.ts
+4
-4
index.wxml
miniprogram/pages/index/index.wxml
+10
-2
store.ts
miniprogram/store/store.ts
+9
-10
config.ts
miniprogram/utils/config.ts
+7
-7
request.ts
miniprogram/utils/request.ts
+75
-28
activity.json
mock备份/activity.json
+29
-0
index.json
mock备份/index.json
+25
-0
login.json
mock备份/login.json
+16
-0
subscribe.json
mock备份/subscribe.json
+11
-0
project.private.config.json
project.private.config.json
+2
-1
tsconfig.json
tsconfig.json
+5
-5
No files found.
miniprogram/app.ts
View file @
ea23f1e7
// app.ts
import
{
dbLogin
,
request
}
from
"./utils/request"
;
App
<
IAppOption
>
({
globalData
:
{},
onLaunch
()
{
...
...
@@ -9,9 +11,10 @@ App<IAppOption>({
// 登录
wx
.
login
({
success
:
res
=>
{
success
:
async
(
res
)
=>
{
console
.
log
(
res
.
code
)
// 发送 res.code 到后台换取 openId, sessionKey, unionId
await
dbLogin
({
code
:
res
.
code
});
},
})
},
...
...
miniprogram/pages/index/index.less
View file @
ea23f1e7
...
...
@@ -149,6 +149,17 @@
}
}
.getPhoneBtn{
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 100vw !important;
height: 100vh;
opacity: 0;
}
// .userinfo {
// display: flex;
...
...
miniprogram/pages/index/index.ts
View file @
ea23f1e7
...
...
@@ -15,6 +15,7 @@ ComponentWithStore({
actions
:
{},
},
data
:
{
showPhoneBtn
:
true
,
showGetPanel
:
false
,
showAlGetPanel
:
false
,
userInfo
:
{
...
...
@@ -25,7 +26,9 @@ ComponentWithStore({
canIUseGetUserProfile
:
wx
.
canIUse
(
'getUserProfile'
),
canIUseNicknameComp
:
wx
.
canIUse
(
'input.type.nickname'
),
},
ready
()
{
store
.
updateHomeInfo
();
},
methods
:
{
getPhoneNumber
(
e
:
any
)
{
console
.
log
(
e
.
detail
)
...
...
@@ -48,9 +51,6 @@ ComponentWithStore({
url
:
'../logs/logs'
,
})
},
changeStore
()
{
store
.
updateHomeInfo
();
},
onChooseAvatar
(
e
:
any
)
{
const
{
avatarUrl
}
=
e
.
detail
const
{
nickName
}
=
this
.
data
.
userInfo
...
...
miniprogram/pages/index/index.wxml
View file @
ea23f1e7
...
...
@@ -6,7 +6,6 @@
</swiper-item>
</swiper>
<view class="user_info">
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">测试手机号</button>
<view class="avatar_box">
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
</view>
...
...
@@ -50,3 +49,12 @@
<get-panel wx:if="{{showGetPanel}}" bind:close="closeGetPanel" />
<al-get-panel wx:if="{{showAlGetPanel}}" bind:close="closeAlGetPanel" />
</view>
<!--获取手机号按钮-->
<button
type="primary"
wx:if="{{showPhoneBtn}}"
class="getPhoneBtn"
open-type="getPhoneNumber"
bindgetphonenumber="getPhoneNumber"
></button>
miniprogram/store/store.ts
View file @
ea23f1e7
import
{
makeAutoObservable
}
from
'mobx-miniprogram'
import
{
request
}
from
"../utils/request"
;
import
{
API_PATH
}
from
"../utils/config"
;
class
Store
{
...
...
@@ -19,16 +21,13 @@ class Store {
]
}
updateHomeInfo
()
{
this
.
homeInfo
=
{
name
:
'张三'
,
age
:
18
,
banner
:
[
"https://yun.duiba.com.cn/polaris/banner.bf4a3033e8bb2cb9eb20c534d002879a2f6b5579.png"
,
"//yun.duiba.com.cn/polaris/%E5%96%9D%E9%B2%9C%E5%A5%B6.5815326bdfc25045c0a8ee71beb10c13b0147acd.png"
,
"//yun.duiba.com.cn/polaris/%E9%B2%9C%E7%89%9B%E5%A5%B6.fd352be87520d04261ba36348022c36836e4c819.png"
]
}
async
updateHomeInfo
()
{
const
res
=
await
request
({
url
:
API_PATH
.
index
,
});
console
.
log
(
res
)
}
}
...
...
miniprogram/utils/config.ts
View file @
ea23f1e7
// 【开发环境】
export
const
devOptions
=
{
BASE_URL
:
'https://activity.m.duibadev.com.cn
/
'
,
BASE_URL
:
'https://activity.m.duibadev.com.cn'
,
appKey
:
'jlg88lyxz7siqtmr'
,
}
// 【测试环境】
export
const
testOptions
=
{
BASE_URL
:
'https://activity.m.duibatest.com.cn
/
'
,
BASE_URL
:
'https://activity.m.duibatest.com.cn'
,
appKey
:
'3tWCs93A2ZfuvMyJkWxC7xddg6qA'
,
projectId
:
"test"
,
}
// 【预发环境】
export
const
prevOptions
=
{
BASE_URL
:
'https://activity-pre.m.duiba.com.cn
/
'
,
// 免登接口有预发的环境
BASE_URL
:
'https://activity-pre.m.duiba.com.cn'
,
// 免登接口有预发的环境
appKey
:
'388ENcX8CGJBEdn2hyZA5zDkqpR6'
,
projectId
:
"prev"
,
}
// 【线上环境】
export
const
publishOptions
=
{
BASE_URL
:
'https://activity.m.duiba.com.cn
/
'
,
BASE_URL
:
'https://activity.m.duiba.com.cn'
,
appKey
:
'388ENcX8CGJBEdn2hyZA5zDkqpR6'
,
projectId
:
"publish"
,
}
...
...
@@ -29,8 +29,8 @@ export default publishOptions;
export
enum
API_PATH
{
index
=
"/home/coop_index.do"
,
activity
=
"/home/coop_activity.do"
,
index
=
"home/coop_index.do"
,
activity
=
"home/coop_activity.do"
,
subscribe
=
"home/coop_subscribe.do"
,
login
=
"/wechat/jlb/login"
,
subscribe
=
"/home/coop_subscribe.do"
,
}
\ No newline at end of file
miniprogram/utils/request.ts
View file @
ea23f1e7
import
env
from
'./config'
;
import
env
,
{
API_PATH
}
from
'./config'
;
const
headersConfig
=
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
...
...
@@ -13,14 +13,22 @@ interface IReqConfig {
method
?:
IReqMethod
;
}
interface
IResData
{
success
:
boolean
;
data
?:
{
[
key
in
string
]:
any
};
code
?:
string
;
message
?:
string
;
}
let
loginToken
:
string
=
""
;
export
const
request
=
(
config
:
IReqConfig
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
export
function
request
(
config
:
IReqConfig
)
{
return
new
Promise
<
IResData
>
((
resolve
,
reject
)
=>
{
const
{
BASE_URL
,
projectId
}
=
env
;
cons
t
{
url
,
headers
,
data
,
method
=
"GET"
}
=
config
;
le
t
{
url
,
headers
,
data
,
method
=
"GET"
}
=
config
;
const
type
=
(
method
.
toUpperCase
()
as
IReqMethod
)
||
'GET'
;
method
=
(
method
.
toUpperCase
()
as
IReqMethod
)
||
'GET'
;
const
header
=
{
...
headersConfig
,
...
...
@@ -32,20 +40,59 @@ export const request = (config: IReqConfig) => new Promise((resolve, reject) =>
...
data
,
};
if
(
url
.
indexOf
(
"/"
)
!=
0
)
{
url
=
`/
${
projectId
}
/
${
url
}
`
;
}
wx
.
request
({
method
:
type
,
url
:
`
${
BASE_URL
}${
projectId
}${
url
}
`
,
method
,
url
:
`
${
BASE_URL
}${
url
}
?_t=
${
Date
.
now
()
}
`
,
data
:
params
,
header
,
success
(
response
)
{
console
.
log
(
1111
,
response
)
if
(
+
response
.
statusCode
===
200
)
{
resolve
(
response
.
d
ata
);
resolve
(
response
.
data
as
IResD
ata
);
}
else
{
reject
(
new
Error
(
`请求失败 statusCode:
${
response
.
statusCode
}
`
));
resolve
({
success
:
false
});
// reject(new Error(`请求失败 statusCode: ${response.statusCode}`));
}
},
fail
(
error
)
{
reject
(
new
Error
(
error
.
errMsg
));
resolve
({
success
:
false
});
// reject(new Error(error.errMsg));
},
})
})
\ No newline at end of file
})
}
export
async
function
dbLogin
(
param
:
{
code
?,
encryptedData
?,
iv
?,
nickname
?,
avatar
?
}
)
{
const
{
code
,
encryptedData
=
null
,
iv
,
nickname
,
avatar
}
=
param
;
const
params
:
any
=
{
appKey
:
env
.
appKey
,
};
code
&&
(
params
.
code
=
code
);
encryptedData
&&
(
encryptedData
.
code
=
encryptedData
);
iv
&&
(
iv
.
code
=
iv
);
nickname
&&
(
nickname
.
code
=
nickname
);
avatar
&&
(
avatar
.
code
=
avatar
);
const
{
success
,
data
}
=
await
request
({
url
:
API_PATH
.
login
,
data
:
params
,
});
if
(
!
success
)
{
return
;
}
loginToken
=
data
.
loginToken
;
}
\ No newline at end of file
mock备份/activity.json
0 → 100644
View file @
ea23f1e7
{
"data"
:
{
"success"
:
true
,
"message"
:
"true"
,
"code"
:
"0"
,
"data"
:
{
"topBanners"
:
[
"https://yun.duiba.com.cn/polaris/%E5%9B%BE%E5%B1%82%20541.3c7ff6d4bed9f88be00c52551b05b54d94d1fd95.png"
,
"//yun.duiba.com.cn/polaris/%E5%96%9D%E9%B2%9C%E5%A5%B6.5815326bdfc25045c0a8ee71beb10c13b0147acd.png"
,
"//yun.duiba.com.cn/polaris/%E9%B2%9C%E7%89%9B%E5%A5%B6.fd352be87520d04261ba36348022c36836e4c819.png"
],
"productList"
:
[
{
"name"
:
"商品1"
,
"img"
:
"//yun.duiba.com.cn/polaris/%E5%96%9D%E9%B2%9C%E5%A5%B6.5815326bdfc25045c0a8ee71beb10c13b0147acd.png"
,
"content"
:
"商品1的内容"
},
{
"name"
:
"商品1"
,
"img"
:
"//yun.duiba.com.cn/polaris/%E9%B2%9C%E7%89%9B%E5%A5%B6.fd352be87520d04261ba36348022c36836e4c819.png"
,
"content"
:
"商品1的内容"
}
]
}
},
"statusCode"
:
200
,
"header"
:
""
}
\ No newline at end of file
mock备份/index.json
0 → 100644
View file @
ea23f1e7
{
"data"
:
{
"success"
:
true
,
"message"
:
"true"
,
"code"
:
"0"
,
"data"
:
{
"nickname"
:
1231231
,
"avatar"
:
1231231
,
"mobile"
:
17606542514
,
"subscribe"
:
false
,
"first"
:
false
,
"topBanners"
:
[
"https://yun.duiba.com.cn/polaris/%E5%9B%BE%E5%B1%82%20541.3c7ff6d4bed9f88be00c52551b05b54d94d1fd95.png"
,
"//yun.duiba.com.cn/polaris/%E5%96%9D%E9%B2%9C%E5%A5%B6.5815326bdfc25045c0a8ee71beb10c13b0147acd.png"
,
"//yun.duiba.com.cn/polaris/%E9%B2%9C%E7%89%9B%E5%A5%B6.fd352be87520d04261ba36348022c36836e4c819.png"
],
"activities"
:
[
"111111111"
]
}
},
"statusCode"
:
200
,
"header"
:
""
}
\ No newline at end of file
mock备份/login.json
0 → 100644
View file @
ea23f1e7
{
"data"
:
{
"success"
:
true
,
"message"
:
"true"
,
"code"
:
"0"
,
"desc"
:
"desc"
,
"timestamp"
:
1719284416812
,
"data"
:
{
"loginToken"
:
"loginToken"
,
"sessionId"
:
"sessionId"
}
},
"statusCode"
:
200
,
"header"
:
""
}
\ No newline at end of file
mock备份/subscribe.json
0 → 100644
View file @
ea23f1e7
{
"data"
:
{
"success"
:
true
,
"message"
:
"true"
,
"code"
:
"0"
,
"data"
:
true
},
"statusCode"
:
200
,
"header"
:
""
}
\ No newline at end of file
project.private.config.json
View file @
ea23f1e7
...
...
@@ -3,7 +3,8 @@
"projectname"
:
"junlebao-milk-20240619"
,
"setting"
:
{
"compileHotReLoad"
:
true
,
"preloadBackgroundData"
:
false
"preloadBackgroundData"
:
false
,
"urlCheck"
:
false
},
"libVersion"
:
"3.4.6"
}
\ No newline at end of file
tsconfig.json
View file @
ea23f1e7
{
"compilerOptions"
:
{
"strictNullChecks"
:
tru
e
,
"noImplicitAny"
:
tru
e
,
"strictNullChecks"
:
fals
e
,
"noImplicitAny"
:
fals
e
,
"module"
:
"CommonJS"
,
"target"
:
"ES2020"
,
"allowJs"
:
true
,
...
...
@@ -12,9 +12,9 @@
"noImplicitReturns"
:
true
,
"alwaysStrict"
:
true
,
"noFallthroughCasesInSwitch"
:
true
,
"noUnusedLocals"
:
tru
e
,
"noUnusedParameters"
:
tru
e
,
"strict"
:
tru
e
,
"noUnusedLocals"
:
fals
e
,
"noUnusedParameters"
:
fals
e
,
"strict"
:
fals
e
,
"strictPropertyInitialization"
:
true
,
"lib"
:
[
"ES2020"
],
"typeRoots"
:
[
...
...
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