Commit 2ebefd8a authored by Facius's avatar Facius

Merge branch 'dev-v1.0.0' of https://git.banshouhui.com/wuzhenzhe/study into dev-v1.0.0

parents cff21a2e c0410a4a
......@@ -44,6 +44,7 @@ export default {
}
.title {
padding-left: 25rpx;
color: #191C27;
}
}
.content {
......@@ -55,6 +56,7 @@ export default {
text-align: left;
padding: 10rpx 0 0rpx 30rpx;
line-height: 50rpx;
color: #5A6073;
}
.lists:nth-of-type(1) {
color: #2953ff;
......
......@@ -15,7 +15,7 @@
></view>
<view class="text">{{ item.text }}</view>
</view>
<view class="btn" v-if="rightKey.length > 1">
<view class="btn" v-if="rightKey.length > 1 && btnStatus">
<view
:class="['confirm', { active: getCheckedNum }]"
@click="confirmMultiple"
......@@ -59,6 +59,10 @@ export default {
type: Boolean,
default: false,
},
btnStatus: {
type: Boolean,
default: true,
}
},
data() {
return {
......@@ -173,6 +177,7 @@ export default {
color: #fff;
}
.text {
color: #191C27;
padding-left: 20rpx;
flex: 1;
}
......
......@@ -124,6 +124,7 @@ export default {
},
answerChange(status, lists) {
this.$set(this.swiperList[this.swiperIndex], 'errShow', this.type === 2 ? true : status === 'fail')
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true)
this.$emit("answerChange", status, lists)
},
clear () {
......
......@@ -55,7 +55,7 @@
/* 快应用特有相关 */
"mp-weixin" : {
/* 微信小程序特有相关 */
"appid" : "wxd1d6eede324b0465",
"appid" : "wx4bd80cf10c2a1d14",
"setting" : {
"urlCheck" : false,
"es6" : true
......
This diff is collapsed.
<template>
<view>
<u-button type="primary" @click="payOrder">微信支付测试</u-button>
</view>
</template>
<script>
import md5 from '@/common/md5.js'
export default {
components: {},
data() {
return {
lists: [
{
questionWarehouseId: 1,
amount: 0.01,
count: 1,
},
],
}
},
methods: {
payOrder() {
const data = {
instrtutionId: 1,
orders: JSON.stringify(this.lists),
openId: this.openId,
}
this.$u.api.payOrder(data).then((res) => {
this.pay(res)
})
},
pay(data) {
const timeStamp = String(Date.now())
const paySign = md5
.hexMD5(
`appId=wxd1d6eede324b0465&nonceStr=${data.nonce_str}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}&key=weixiuhui20151a2b3c4d5e6f7g8h9ij`
)
.toUpperCase()
uni.requestPayment({
provider: 'wxpay',
timeStamp: timeStamp,
nonceStr: data.nonce_str,
package: `prepay_id=${data.prepay_id}`,
signType: 'MD5',
paySign: paySign,
success: (res) => {
console.log('success:' + JSON.stringify(res))
this.checkPayStatus(data.out_trade_no)
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err))
if (err.errMsg === 'requestPayment:fail cancel') {
this.$u.toast('取消支付')
} else {
this.checkPayStatus(data.out_trade_no)
}
},
})
},
checkPayStatus(no) {
const params = {
outTradeNo: no
}
this.$u.api.payQuery(params).then(res => {
if (res.trade_state === 'SUCCESS') {
this.$u.toast('支付成功')
} else if (res.trade_state === 'NOTPAY') {
this.$u.toast('请稍后核实订单状态,不要重复发起支付')
} else if (res.trade_state === 'PAYERROR') {
this.$u.toast('支付失败')
} else {
this.$u.toast(res.trade_state_desc)
}
})
}
},
}
</script>
<style lang="scss" scoped></style>
......@@ -87,6 +87,7 @@
</template>
<script>
import md5 from '@/common/md5.js'
export default {
data() {
return {
......@@ -99,6 +100,13 @@ export default {
trueOrFalse: 526,
total: 986,
},
lists: [
{
questionWarehouseId: 1,
amount: 0.01,
count: 1,
},
],
}
},
......@@ -179,7 +187,61 @@ export default {
url: '/pages/index/index',
})
},
handleClickBuy() {},
handleClickBuy() {
const data = {
instrtutionId: 1,
orders: JSON.stringify(this.lists),
openId: this.openId,
}
this.$u.api.payOrder(data).then((res) => {
this.pay(res)
})
},
pay(data) {
const timeStamp = String(Date.now())
const paySign = md5
.hexMD5(
`appId=wx4bd80cf10c2a1d14&nonceStr=${data.nonce_str}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}&key=304b5d1810e481224d4a9199e8ba6c6e`
)
.toUpperCase()
uni.requestPayment({
provider: 'wxpay',
timeStamp: timeStamp,
nonceStr: data.nonce_str,
package: `prepay_id=${data.prepay_id}`,
signType: 'MD5',
paySign: paySign,
success: (res) => {
console.log('success:' + JSON.stringify(res))
this.checkPayStatus(data.out_trade_no)
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err))
if (err.errMsg === 'requestPayment:fail cancel') {
this.$u.toast('取消支付')
} else {
this.checkPayStatus(data.out_trade_no)
}
},
})
},
checkPayStatus(no) {
const params = {
outTradeNo: no
}
this.$u.api.payQuery(params).then(res => {
if (res.trade_state === 'SUCCESS') {
this.$u.toast('支付成功')
} else if (res.trade_state === 'NOTPAY') {
this.$u.toast('请稍后核实订单状态,不要重复发起支付')
} else if (res.trade_state === 'PAYERROR') {
this.$u.toast('支付失败')
} else {
this.$u.toast(res.trade_state_desc)
}
})
}
},
}
</script>
......
<template>
<view class="search">
<view class="u-flex search">
<u-navbar
back-icon-color="#333333"
background="transparent"
title=" "
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="search-bar">
<u-search
:clearabled="true"
:action-style="searchStyle"
bg-color="#fff"
v-model="keyword"
:show-action="false"
@custom="search"
@search="search"
></u-search>
</view>
<view v-show="lists.length > 0">
<view class="title"
>共找到含有<text>“{{ keyword }}”</text>相关试题<text>10</text>道</view
>
<view class="result">
<u-collapse :item-style="itemStyle" event-type="close">
<u-collapse-item
:ref="`collapse${index}`"
:index="index"
@change="itemChange"
v-for="(item, index) in lists"
:key="index"
>
<view slot="title-all" class="u-flex head">
<view class="titles">
<text>{{ titleType[item.type - 1] }}</text
>{{ item.title }}
</view>
<view class="u-flex arrow" v-show="index !== arrIndex">
<text>展开</text>
<u-icon name="arrow-down" color="#9EA5BB"></u-icon>
</view>
</view>
<view class="u-flex subject">
<view class="content">
<answer-sheet
ref="answerSheet"
:answerList="item.answerList"
:rightKey="item.rightKey"
:multiple="item.type === 3"
:submitStatus="item.submitStatus"
:btnStatus="false"
@change="answerChange"
></answer-sheet>
</view>
<view class="explain">
<answer-explanation
:answer="item.answer"
:explain="item.explain"
></answer-explanation>
</view>
</view>
<view class="u-flex opera">
<view class="opera-list" @click="collection(item)">
<u-icon name="star" color="#5A6073" size="40"></u-icon>
<text>收藏</text>
</view>
<view class="opera-list" @click="arrowUp(index)">
<text>收起</text>
<u-icon name="arrow-up" color="#9EA5BB"></u-icon>
</view>
</view>
</u-collapse-item>
</u-collapse>
</view>
</view>
<view class="u-flex default" v-show="lists.length === 0">
<view>
<image :src="defaultImg" />
</view>
<view class="no-result">
当前暂无搜索结果
</view>
</view>
</view>
</template>
<script>
import answerSheet from '@/components/answer-sheet/index.vue'
import answerExplanation from '@/components/answer-explanation/index.vue'
export default {
components: {
answerSheet,
answerExplanation,
},
data() {
return {
keyword: ''
itemStyle: {
background: '#fff',
padding: '0rpx 20rpx',
margin: '10rpx 0',
'border-radius': '30rpx 30rpx 0 0'
},
titleType: ['单选题', '判断题', '多选题'],
keyword: '',
lists: [
{
type: 1,
title: '采用QS1电桥测量tanδ的接线方式一般有差接线及和接线。',
answerList: [
{
sort: 'A',
text: '正确',
checked: true,
confirm: true,
},
{
sort: 'B',
text: '错误',
},
],
answer: 'A',
explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 0,
rightKey: ['A'],
submitStatus: true,
},
{
type: 2,
title:
'空气间隙的操作冲击击穿电压数值大小不仅与间隙距离、电极形状、电极极性有关,而且与操作冲击电压波的波前时间的长短有关。',
answerList: [
{
sort: 'A',
text: '正确',
},
{
sort: 'B',
text: '错误',
checked: true,
confirm: true,
},
],
answer: 'B',
explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 1,
rightKey: ['B'],
submitStatus: true,
},
{
type: 3,
title: '西林电桥采用正接线及反接线时,其测试原理相同',
answerList: [
{
sort: 'A',
text: '影响',
},
{
sort: 'B',
text: '影响很小',
checked: true,
confirm: true,
},
{
sort: 'C',
text: '影响很大',
checked: true,
confirm: true,
},
{
sort: 'D',
text: '无影响',
},
],
answer: 'B,C',
explain:
'双臂电桥是在单臂电桥的基础上增加特殊机构,以消除测试时连接线和接线柱接触电阻对测量结果的影响。',
index: 2,
rightKey: ['B', 'C'],
submitStatus: true,
},
{
type: 2,
title: '测试标题测试标题测试标题测试标题',
answerList: [
{
sort: 'A',
text: '是',
},
{
sort: 'B',
text: '否',
checked: true,
confirm: true,
},
],
answer: 'B',
explain: '测试内容测试内容测试内容测试内容测试内容测试内容',
index: 3,
rightKey: ['B'],
submitStatus: true,
},
],
arrIndex: null,
}
},
onLoad(e) {
this.keyword = e ? decodeURIComponent(e.keyword) : ''
},
computed: {
defaultImg() {
return process.uniEnv.qn_base_url + 'no-search.png'
},
},
methods: {
itemChange(e) {
this.arrIndex = e.show ? e.index : null
},
search(val) {
this.keyword = val
let history = this.searchHistory
history.unshift(val)
if (history.length > 9) {
history.splice(9, 1)
}
this.$u.vuex('searchHistory', history)
},
collection(item) {
console.log("item", item)
},
arrowUp(index) {
this.$refs[`collapse${index}`][0].headClick()
}
},
}
</script>
......@@ -27,6 +250,99 @@ export default {
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
padding: 0 20rpx;
.search-bar {
width: 100%;
padding: 0 20rpx;
}
.title {
width: 100%;
color: #191c27;
font-size: 32rpx;
font-weight: bold;
margin-top: 30rpx;
padding: 0 20rpx;
text {
color: #2953ff;
}
}
.result {
margin-top: 30rpx;
width: 100%;
.head {
width: 100%;
height: 60rpx;
overflow: hidden;
.titles {
color: #191c27;
font-size: 32rpx;
line-height: 50rpx;
font-weight: bold;
height: 60rpx;
overflow: hidden;
flex: 1;
text {
background: #9ea5bb;
color: #fff;
padding: 8rpx 20rpx;
margin-right: 10rpx;
font-size: 20rpx;
border-radius: 50rpx;
}
}
.arrow {
padding-left: 20rpx;
text {
color: #2953ff;
font-size: 28rpx;
padding-right: 10rpx;
}
}
}
.subject {
flex-flow: column;
.type {
width: 100%;
text-align: left;
padding: 20rpx 0;
}
.content {
width: 100%;
}
.explain,
.btn {
width: 100%;
padding-top: 50rpx;
}
}
.opera {
padding: 30rpx 0;
justify-content: space-between;
color: #5a6073;
font-size: 28rpx;
.opera-list {
display: flex;
&:nth-of-type(1) {
text {
padding-left: 10rpx;
}
}
&:nth-of-type(2) {
text {
padding-right: 10rpx;
color: #2953ff;
}
}
}
}
}
.default {
flex-flow: column;
flex: 1;
justify-content: center;
.no-result {
color: #9EA5BB;
font-size: 28rpx;
}
}
}
</style>
......@@ -3,7 +3,7 @@
<u-navbar
back-icon-color="#333333"
background="transparent"
title="搜索"
title=" "
titleColor="#191C27"
:border-bottom="false"
title-bold
......@@ -63,7 +63,10 @@ export default {
methods: {
search(val) {
this.keyword = val
this.history.push(val)
this.history.unshift(val)
if(this.history.length > 9){
this.history.splice(9, 1)
}
this.$u.vuex('searchHistory', this.history)
this.toSearchDetail(val)
},
......
......@@ -12,7 +12,7 @@ try{
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let saveStateKeys = ['userInfo', 'vuex_token', 'openId', 'searchHistory'];
let saveStateKeys = ['userInfo', 'vuex_token', 'openId', 'searchHistory', 'questionList'];
// 保存变量到本地存储中
const saveLifeData = function(key, value){
......@@ -35,9 +35,10 @@ const store = new Vuex.Store({
userInfo: lifeData.userInfo ? lifeData.userInfo : {},
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
openId: lifeData.openId ? lifeData.openId : '',
searchHistory: lifeData.searchHistory ? lifeData.searchHistory : [],
searchHistory: lifeData.searchHistory ? lifeData.searchHistory : [], // 搜索历史记录
questionList: lifeData.questionList ? lifeData.questionList : [], // 练习列表
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_version: '1.0.1',
vuex_version: '1.0.0',
},
mutations: {
$uStore(state, payload) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment