Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
43443090
Commit
43443090
authored
Jan 11, 2022
by
柳士祥
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序文章优化
parent
5c717289
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
21 deletions
+48
-21
src/pages/pages_subpack/article/index.vue
+29
-4
src/pages/wxPay/index.vue
+19
-17
No files found.
src/pages/pages_subpack/article/index.vue
View file @
43443090
...
...
@@ -7,7 +7,7 @@
<div
class=
"title_time"
>
{{
article
.
createDatetime
}}
</div>
</div>
<div
v-html=
"article.content"
v-if=
"!article.msg"
></div>
<!--
<rich-text
:datas=
"datas"
v-if=
"!article.msg"
></rich-text>
-->
<div
class=
"title"
style=
"min-height: 50vh;color: #999;align-items: center;display: flex;justify-content: center;"
v-else
>
{{
article
.
msg
}}
</div>
</div>
<div
style=
"width:100%;height:10px;background-color:#EEF2F5;"
></div>
...
...
@@ -52,6 +52,7 @@
<
script
>
import
article
from
'@/api/article'
import
shadeGuide
from
"./shadeGuide.vue"
;
import
richText
from
"../../../components/basicTool/rich-text/index.vue"
;
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
...
...
@@ -69,11 +70,15 @@ export default {
query
:
{
pageNum
:
0
,
pageSize
:
20
,
},
datas
:
{
componentData
:
{}
}
}
},
components
:
{
"shade-guide"
:
shadeGuide
,
"rich-text"
:
richText
},
created
()
{
},
...
...
@@ -105,13 +110,32 @@ export default {
}
},
methods
:
{
formatRichText
(
html
)
{
console
.
log
(
html
,
'html'
);
let
newContent
=
html
.
replace
(
/<img
[^
>
]
*>/gi
,
function
(
match
,
capture
)
{
match
=
match
.
replace
(
/style="
[^
"
]
+"/gi
,
''
).
replace
(
/style='
[^
'
]
+'/gi
,
''
);
match
=
match
.
replace
(
/width="
[^
"
]
+"/gi
,
''
).
replace
(
/width='
[^
'
]
+'/gi
,
''
);
match
=
match
.
replace
(
/height="
[^
"
]
+"/gi
,
''
).
replace
(
/height='
[^
'
]
+'/gi
,
''
);
return
match
;
});
newContent
=
newContent
.
replace
(
/style="
[^
"
]
+"/gi
,
function
(
match
,
capture
)
{
match
=
match
.
replace
(
/width:
[^
;
]
+;/gi
,
'max-width:100%;'
).
replace
(
/width:
[^
;
]
+;/gi
,
'max-width:100%;'
);
return
match
;
});
newContent
=
newContent
.
replace
(
/<br
[^
>
]
*
\/
>/gi
,
''
);
newContent
=
newContent
.
replace
(
/\<img/gi
,
'<img style="max-width:100%;height:auto;display:block;margin:10px 0;"'
);
return
newContent
},
init
()
{
log
.
info
(
'qq'
);
article
.
getArticleInfo
(
this
.
articleId
).
then
(
res
=>
{
if
(
res
.
data
.
data
)
{
let
article
=
res
.
data
.
data
let
content
=
res
.
data
.
data
.
content
.
replace
(
"<body>"
,
""
).
replace
(
"</body>"
,
""
)
article
.
content
=
content
article
.
content
=
this
.
formatRichText
(
content
)
this
.
datas
.
componentData
[
'padding'
]
=
0
this
.
datas
.
componentData
[
'richText'
]
=
content
this
.
datas
.
componentData
[
'backgroundColor'
]
=
'#fff'
this
.
article
=
article
// this.createDatetime = article.createDatetime != '' ? article.createDatetime.slice(0,-3):''
// log.info(this.createDatetime,'article.createDatetime');
...
...
@@ -264,8 +288,9 @@ export default {
.title_info
{
display
:
flex
;
justify-content
:
center
;
padding
:
0
12px
;
//
padding
:
0
12px
;
font-size
:
13px
;
margin-bottom
:
12px
;
}
.title_user
{
width
:
100%
;
...
...
@@ -273,7 +298,7 @@ export default {
}
.title_time
{
width
:
100%
;
padding-right
:
13px
;
//
padding-right
:
13px
;
text-align
:
right
;
color
:
#999
;
}
...
...
src/pages/wxPay/index.vue
View file @
43443090
...
...
@@ -5,6 +5,8 @@
<
script
>
import
{
formatTime
}
from
"@/utils/index"
;
import
wxPay
from
"@/api/wxPay"
;
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
components
:
{
// card
...
...
@@ -30,14 +32,14 @@ export default {
title
:
"加载中"
,
});
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
console
.
log
(
"onload//"
,
options
);
log
.
info
(
"onload//"
,
options
);
if
(
options
.
batchNumber
)
{
let
ordercode
=
JSON
.
parse
(
options
.
ordercode
);
ordercode
.
orderSn
=
""
;
ordercode
.
batchNumber
=
options
.
batchNumber
;
this
.
options
=
ordercode
;
this
.
batchNumber
=
ordercode
.
batchNumber
;
console
.
log
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
);
log
.
info
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
);
if
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
)
{
this
.
totalMoney
=
Number
(
JSON
.
parse
(
options
.
ordercode
).
orderSn
.
totalAmount
...
...
@@ -49,7 +51,7 @@ export default {
}
// }
console
.
log
(
this
.
totalMoney
,
"totalMoney"
);
log
.
info
(
this
.
totalMoney
,
"totalMoney"
);
}
else
{
this
.
options
=
JSON
.
parse
(
options
.
ordercode
);
options
.
scene
&&
(
this
.
scene
=
options
.
scene
);
...
...
@@ -68,15 +70,15 @@ export default {
wx
.
getStorage
({
key
:
"openid"
,
success
(
res
)
{
console
.
log
(
that
.
options
,
"++++"
);
console
.
log
(
res
,
"openid"
);
log
.
info
(
that
.
options
,
"++++"
);
log
.
info
(
res
,
"openid"
);
that
.
options
.
openId
=
res
.
data
;
that
.
options
.
tradeType
=
"Mini"
;
console
.
log
(
"支付开始"
,
that
.
options
);
log
.
info
(
"支付开始"
,
that
.
options
);
that
.
toPay
();
},
fail
(
err
)
{
console
.
log
(
"获取err"
,
err
);
log
.
info
(
"获取err"
,
err
);
},
});
},
...
...
@@ -88,9 +90,9 @@ export default {
wx
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
let
payData
=
JSON
.
parse
(
res
.
data
.
data
);
console
.
log
(
"wxPay"
,
res
.
data
);
log
.
info
(
"wxPay"
,
res
.
data
);
payData
.
success
=
(
res
)
=>
{
console
.
log
(
"支付成功"
,
res
,
this
.
options
);
log
.
info
(
"支付成功"
,
res
,
this
.
options
);
this
.
message
=
"支付成功"
;
const
orderSn
=
this
.
options
.
orderSn
;
let
vm
=
this
;
...
...
@@ -123,18 +125,18 @@ export default {
tmplIds
:
tmplIds
,
success
(
res
)
{
fn
(
vm
);
console
.
log
(
"message success response: "
,
res
);
log
.
info
(
"message success response: "
,
res
);
},
fail
(
res
)
{
fn
(
vm
);
console
.
log
(
"message fail response: "
,
res
);
log
.
info
(
"message fail response: "
,
res
);
},
});
}
else
{
fn
(
vm
);
}
}
else
{
console
.
log
(
"来这里了"
);
log
.
info
(
"来这里了"
);
fn
(
this
);
}
}
catch
(
err
)
{
...
...
@@ -184,19 +186,19 @@ export default {
}
};
payData
.
fail
=
(
res
)
=>
{
console
.
log
(
"支付失败"
,
res
,
this
.
options
.
orderSn
);
log
.
info
(
"支付失败"
,
res
,
this
.
options
.
orderSn
);
this
.
message
=
"支付失败"
;
if
((
res
.
errMsg
=
"requestPayment:fail cancel"
))
{
wxPay
.
cancelPayment
(
this
.
options
.
orderSn
).
then
(()
=>
{
console
.
log
(
"取消成功"
);
log
.
info
(
"取消成功"
);
});
}
this
.
toPage
();
};
payData
.
complete
=
(
res
)
=>
{
console
.
log
(
"支付completa"
,
res
,
this
.
options
.
orderSn
);
log
.
info
(
"支付completa"
,
res
,
this
.
options
.
orderSn
);
// if (res.errMsg == "requestPayment:fail cancel") {
//
console.log
("支付取消", this.options);
//
log.info
("支付取消", this.options);
// this.message = "支付取消";
// this.toPage();
// }
...
...
@@ -211,7 +213,7 @@ export default {
});
},
toPage
()
{
console
.
log
(
log
.
info
(
"支付失败来这里了"
,
this
.
backUrl
,
this
.
batchNumber
,
...
...
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