Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-shop-show-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-shop-show-h5
Commits
b7486b7e
提交
b7486b7e
authored
6月 08, 2021
作者:
pengxiaohui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of gitlab.ezijing.com:webapp/shop-h5
上级
684f35e4
6a16141d
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
118 行增加
和
5 行删除
+118
-5
package-lock.json
package-lock.json
+11
-0
package.json
package.json
+1
-0
account.js
src/api/account.js
+14
-2
Upload.vue
src/components/Upload.vue
+80
-0
BuyPopup.vue
src/pages/buy/components/BuyPopup.vue
+12
-3
没有找到文件。
package-lock.json
浏览文件 @
b7486b7e
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
"license"
:
"ISC"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"dependencies"
:
{
"axios"
:
"^0.20.0"
,
"axios"
:
"^0.20.0"
,
"blueimp-md5"
:
"^2.18.0"
,
"core-js"
:
"^3.6.5"
,
"core-js"
:
"^3.6.5"
,
"cross-env"
:
"^7.0.2"
,
"cross-env"
:
"^7.0.2"
,
"js-cookie"
:
"^2.2.1"
,
"js-cookie"
:
"^2.2.1"
,
...
@@ -2552,6 +2553,11 @@
...
@@ -2552,6 +2553,11 @@
"version"
:
"3.7.2"
,
"version"
:
"3.7.2"
,
"license"
:
"MIT"
"license"
:
"MIT"
},
},
"node_modules/blueimp-md5"
:
{
"version"
:
"2.18.0"
,
"resolved"
:
"https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.18.0.tgz"
,
"integrity"
:
"sha512-vE52okJvzsVWhcgUHOv+69OG3Mdg151xyn41aVQN/5W5S+S43qZhxECtYLAEHMSFWX6Mv5IZrzj3T5+JqXfj5Q=="
},
"node_modules/bn.js"
:
{
"node_modules/bn.js"
:
{
"version"
:
"5.1.2"
,
"version"
:
"5.1.2"
,
"license"
:
"MIT"
"license"
:
"MIT"
...
@@ -14889,6 +14895,11 @@
...
@@ -14889,6 +14895,11 @@
"bluebird"
:
{
"bluebird"
:
{
"version"
:
"3.7.2"
"version"
:
"3.7.2"
},
},
"blueimp-md5"
:
{
"version"
:
"2.18.0"
,
"resolved"
:
"https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.18.0.tgz"
,
"integrity"
:
"sha512-vE52okJvzsVWhcgUHOv+69OG3Mdg151xyn41aVQN/5W5S+S43qZhxECtYLAEHMSFWX6Mv5IZrzj3T5+JqXfj5Q=="
},
"bn.js"
:
{
"bn.js"
:
{
"version"
:
"5.1.2"
"version"
:
"5.1.2"
},
},
...
...
package.json
浏览文件 @
b7486b7e
...
@@ -70,6 +70,7 @@
...
@@ -70,6 +70,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"
axios
"
:
"^0.20.0"
,
"
axios
"
:
"^0.20.0"
,
"
blueimp-md5
"
:
"^2.18.0"
,
"
core-js
"
:
"^3.6.5"
,
"
core-js
"
:
"^3.6.5"
,
"
cross-env
"
:
"^7.0.2"
,
"
cross-env
"
:
"^7.0.2"
,
"
js-cookie
"
:
"^2.2.1"
,
"
js-cookie
"
:
"^2.2.1"
,
...
...
src/api/account.js
浏览文件 @
b7486b7e
...
@@ -36,4 +36,17 @@ export function getOpenId(data) {
...
@@ -36,4 +36,17 @@ export function getOpenId(data) {
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
data
data
})
})
}
}
\ No newline at end of file
// 获取oss signature
export
function
getSignature
()
{
return
httpRequest
.
get
(
'/api/usercenter/aliyun/get-signature'
)
}
// 图片上传
export
function
uploadFile
(
data
)
{
return
httpRequest
.
post
(
'https://webapp-pub.oss-cn-beijing.aliyuncs.com'
,
data
,
{
withCredentials
:
false
,
headers
:
{
'Content-Type'
:
'multipart/form-data'
}
})
}
src/components/Upload.vue
0 → 100644
浏览文件 @
b7486b7e
<
template
>
<van-uploader
v-model=
"fileList"
:before-read=
"beforeRead"
:after-read=
"afterRead"
:max-size=
"maxSize"
@
delete=
"onDelete"
@
oversize=
"oversize"
v-bind=
"$attrs"
>
</van-uploader>
</
template
>
<
script
>
import
md5
from
'blueimp-md5'
import
{
uploadFile
,
getSignature
}
from
'@/api/account'
export
default
{
name
:
'Upload'
,
// 最大3M
props
:
{
value
:
String
,
maxSize
:
{
type
:
Number
,
default
:
3
*
1024
*
1024
},
prefix
:
{
type
:
String
,
default
:
'upload/h5-shop/'
}
},
data
()
{
return
{
fileList
:
[],
data
:
{}
}
},
watch
:
{
value
:
{
immediate
:
true
,
handler
(
value
)
{
this
.
fileList
=
value
?
[{
url
:
value
}]
:
[]
}
}
},
methods
:
{
oversize
(
file
)
{
const
rawFile
=
file
.
file
if
(
rawFile
.
size
>
this
.
maxSize
)
{
this
.
$toast
(
`文件大小不能超过
${
this
.
maxSize
/
1024
}
K`
)
}
},
beforeRead
(
file
)
{
const
fileName
=
file
.
name
const
key
=
this
.
prefix
+
md5
(
fileName
+
new
Date
().
getTime
())
+
fileName
.
substr
(
fileName
.
lastIndexOf
(
'.'
))
return
new
Promise
((
resolve
,
reject
)
=>
{
getSignature
()
.
then
(
response
=>
{
const
{
accessid
,
policy
,
signature
,
host
}
=
response
this
.
data
=
{
key
,
OSSAccessKeyId
:
accessid
,
policy
,
signature
,
success_action_status
:
'200'
}
file
.
url
=
`
${
host
}
/
${
key
}
`
resolve
(
file
)
})
.
catch
(
err
=>
{
console
.
log
(
err
)
reject
(
err
)
})
})
},
afterRead
(
file
)
{
const
rawFile
=
file
.
file
file
.
status
=
'uploading'
file
.
message
=
'上传中...'
uploadFile
(
Object
.
assign
({},
this
.
data
,
{
file
:
rawFile
}))
.
then
(()
=>
{
file
.
status
=
'done'
this
.
$emit
(
'input'
,
rawFile
.
url
)
})
.
catch
(()
=>
{
file
.
status
=
'failed'
file
.
message
=
'上传失败'
})
},
onDelete
()
{
this
.
$emit
(
'input'
,
''
)
}
}
}
</
script
>
src/pages/buy/components/BuyPopup.vue
浏览文件 @
b7486b7e
...
@@ -23,7 +23,11 @@
...
@@ -23,7 +23,11 @@
</div>
</div>
</
template
>
</
template
>
</van-field>
</van-field>
<van-field
v-for=
"item in fieldsMap"
v-model=
"form[item.key]"
:key=
"item.key"
:name=
"item.key"
:label=
"item.label"
:type=
"item.type"
:placeholder=
"item.placeholder"
:rules=
"[{ required: item.required, message: item.placeholder }, { validator: item.validator, message: item.errorMsg || '输入格式有误' }]"
/>
<van-field
v-for=
"item in fieldsMap"
v-model=
"form[item.key]"
:key=
"item.key"
:name=
"item.key"
:label=
"item.label"
:type=
"item.type"
:placeholder=
"item.placeholder"
:rules=
"[{ required: item.required, message: item.placeholder }, { validator: item.validator, message: item.errorMsg || '输入格式有误' }]"
>
<
template
#
input
v-if=
"item.type === 'image'"
>
<app-upload
v-model=
"form[item.key]"
:max-count=
"1"
></app-upload>
</
template
>
</van-field>
<div
style=
"margin: 16px;"
>
<div
style=
"margin: 16px;"
>
<van-button
type=
"primary"
round
block
color=
"#C01540"
size=
"small"
>
下一步
</van-button>
<van-button
type=
"primary"
round
block
color=
"#C01540"
size=
"small"
>
下一步
</van-button>
</div>
</div>
...
@@ -40,8 +44,9 @@
...
@@ -40,8 +44,9 @@
import
TagSelection
from
'@/components/TagSelection.vue'
import
TagSelection
from
'@/components/TagSelection.vue'
import
{
getGoodsSpecs
}
from
'@/api/common'
import
{
getGoodsSpecs
}
from
'@/api/common'
import
{
mapGetters
}
from
'vuex'
import
{
mapGetters
}
from
'vuex'
import
AppUpload
from
'@/components/Upload'
export
default
{
export
default
{
components
:
{
TagSelection
},
components
:
{
TagSelection
,
AppUpload
},
props
:
{
props
:
{
value
:
{
value
:
{
type
:
Boolean
,
type
:
Boolean
,
...
@@ -168,12 +173,13 @@ export default {
...
@@ -168,12 +173,13 @@ export default {
assembleFields
(
list
)
{
assembleFields
(
list
)
{
const
map
=
{
const
map
=
{
text
:
{
type
:
'text'
,
placeholder
:
'请填写留言'
},
text
:
{
type
:
'text'
,
placeholder
:
'请填写留言'
},
textarea
:
{
type
:
'textarea'
,
placeholder
:
'请填写留言'
},
number
:
{
type
:
'number'
,
placeholder
:
'请填写数字'
},
number
:
{
type
:
'number'
,
placeholder
:
'请填写数字'
},
email
:
{
type
:
'text'
,
placeholder
:
'请填写邮箱'
,
errorMsg
:
'邮箱格式有误'
},
email
:
{
type
:
'text'
,
placeholder
:
'请填写邮箱'
,
errorMsg
:
'邮箱格式有误'
},
date
:
{
type
:
'text'
,
placeholder
:
'请填写日期'
},
date
:
{
type
:
'text'
,
placeholder
:
'请填写日期'
},
time
:
{
type
:
'text'
,
placeholder
:
'请填写时间'
},
time
:
{
type
:
'text'
,
placeholder
:
'请填写时间'
},
id
:
{
type
:
'text'
,
placeholder
:
'请填写身份证号'
,
errorMsg
:
'身份证格式有误'
},
id
:
{
type
:
'text'
,
placeholder
:
'请填写身份证号'
,
errorMsg
:
'身份证格式有误'
},
image
:
{
type
:
'
text
'
,
placeholder
:
'请上传图片'
},
image
:
{
type
:
'
image
'
,
placeholder
:
'请上传图片'
},
phone
:
{
type
:
'tel'
,
placeholder
:
'请填写手机号'
,
errorMsg
:
'手机格式有误'
}
phone
:
{
type
:
'tel'
,
placeholder
:
'请填写手机号'
,
errorMsg
:
'手机格式有误'
}
}
}
const
fieldsMap
=
{}
const
fieldsMap
=
{}
...
@@ -190,6 +196,9 @@ export default {
...
@@ -190,6 +196,9 @@ export default {
if
(
this
.
validatorMap
[
item
.
type
])
{
if
(
this
.
validatorMap
[
item
.
type
])
{
field
.
validator
=
this
.
validatorMap
[
item
.
type
]
field
.
validator
=
this
.
validatorMap
[
item
.
type
]
}
}
if
(
item
.
multiple
)
{
item
.
type
=
'textarea'
}
fieldsMap
[
field
.
key
]
=
Object
.
assign
({},
field
,
map
[
item
.
type
])
fieldsMap
[
field
.
key
]
=
Object
.
assign
({},
field
,
map
[
item
.
type
])
})
})
this
.
fieldsMap
=
fieldsMap
this
.
fieldsMap
=
fieldsMap
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论