浏览代码

静态页面

1002884655 4 年前
父节点
当前提交
3e78df7db2

+ 72
- 14
src/pages/Index/BookAnswer/index.vue 查看文件

@@ -8,18 +8,22 @@
8 8
               <view class="Title">
9 9
                 <text>{{item.title}}</text>
10 10
               </view>
11
-              <!-- <label class="checkbox" v-if="item.answerType === 'checkbox'">
12
-                <checkbox value="cb" checked="false" />{{item.optionA}}
13
-              </label>
14
-              <label class="checkbox" v-if="item.answerType === 'checkbox'">
15
-                <checkbox value="cb" checked="false" />{{item.optionB}}
16
-              </label>
17
-              <label class="checkbox" v-if="item.answerType === 'checkbox'">
18
-                <checkbox value="cb" checked="false" />{{item.optionC}}
19
-              </label>
20
-              <label class="checkbox" v-if="item.answerType === 'checkbox'">
21
-                <checkbox value="cb" checked="false" />{{item.optionD}}
22
-              </label> -->
11
+
12
+              <checkbox-group @change="CheckboxChange(item, index, $event)" v-if="item.answerType === 'checkbox'" style="padding-top: 10px;">
13
+                <label class="checkbox">
14
+                  <checkbox value="A" :checked="false" />{{item.optionA}}
15
+                </label>
16
+                <label class="checkbox">
17
+                  <checkbox value="B" :checked="false" />{{item.optionB}}
18
+                </label>
19
+                <label class="checkbox">
20
+                  <checkbox value="C" :checked="false" />{{item.optionC}}
21
+                </label>
22
+                <label class="checkbox">
23
+                  <checkbox value="D" :checked="false" />{{item.optionD}}
24
+                </label>
25
+              </checkbox-group>
26
+
23 27
               <radio-group @change="RadioChange(item, index, $event)" v-if="item.answerType === 'radio'">
24 28
                 <label>
25 29
                   <view>
@@ -46,8 +50,27 @@
46 50
                   <view>{{item.optionD}}</view>
47 51
                 </label>
48 52
               </radio-group>
53
+
54
+              <radio-group @change="RadioChange(item, index, $event)" v-if="item.answerType === 'switch'">
55
+                <label>
56
+                  <view>
57
+                    <radio value="A" :checked="false" />
58
+                  </view>
59
+                  <view>{{item.optionA}}</view>
60
+                </label>
61
+                <label>
62
+                  <view>
63
+                    <radio value="B" :checked="false" />
64
+                  </view>
65
+                  <view>{{item.optionB}}</view>
66
+                </label>
67
+              </radio-group>
68
+
49 69
             </view>
50 70
           </view>
71
+          <view class="Submit">
72
+            <text @tap="Submit">提交</text>
73
+          </view>
51 74
         </scroll-view>
52 75
         <PageBottom></PageBottom>
53 76
       </view>
@@ -61,6 +84,7 @@ import MainPage from '../../../components/MainPage'
61 84
 import PageBottom from '../../../components/PageBottom'
62 85
 import { createNamespacedHelpers } from 'vuex'
63 86
 const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
87
+const { mapActions: mapIndexActions } = createNamespacedHelpers('index')
64 88
 export default {
65 89
   name: 'BookDetail',
66 90
   data () {
@@ -90,8 +114,42 @@ export default {
90 114
     ]),
91 115
     ...mapUserMutations([
92 116
     ]),
93
-    RadioChange (item, index, e) {
94
-      console.log(item, index, e.detail.value)
117
+    ...mapIndexActions([
118
+      'PostArticleAnswer'
119
+    ]),
120
+    Submit () {
121
+      let Bool = true
122
+      this.ArticleInfo.postTestList.map((item) => {
123
+        if (item.correctAnswers === null || item.correctAnswers === '') {
124
+          Bool = false
125
+        }
126
+      })
127
+      if (Bool && !this.DataLock) {
128
+        this.DataLock = true
129
+        this.PostArticleAnswer({ data: { data: this.ArticleInfo.postTestList } }).then(() => {
130
+          wx.showToast({
131
+            title: '提交成功',
132
+            icon: 'none',
133
+            duration: 2000
134
+          })
135
+          this.DataLock = false
136
+          wx.navigateBack({ changed: true })
137
+        }).catch(() => {
138
+          this.DataLock = false
139
+        })
140
+      }
141
+    },
142
+    RadioChange (item, index, e) { // 单选
143
+      item.correctAnswers = e.detail.value
144
+    },
145
+    CheckboxChange (item, index, e) { // 多选
146
+      let Arr = []
147
+      if (item.correctAnswers !== null && item.correctAnswers !== '') {
148
+        Arr = item.correctAnswers.split(',')
149
+      }
150
+      Arr.push(e.detail.value)
151
+      Arr = [...new Set(Arr)]
152
+      item.correctAnswers = Arr[Arr.length - 1].join(',')
95 153
     },
96 154
     Init () {
97 155
       if (this.UserInfo !== null) {

+ 43
- 163
src/pages/Index/BookAnswer/page.scss 查看文件

@@ -3,186 +3,66 @@
3 3
   height: 100%;
4 4
   overflow: hidden;
5 5
   background: #f8f8f8;
6
-  > .flex-item {
6
+  .QuestionList {
7 7
     position: relative;
8 8
     overflow: hidden;
9
+    padding: 0 30px;
9 10
     > view {
10
-      width: 100%;
11
-      position: absolute;
12
-      left: 0;
13
-      top: 0;
14
-      bottom: 0;
15
-      overflow-y: scroll;
16
-      -webkit-overflow-scrolling: touch;
17
-      > .FrontInfo {
11
+      position: relative;
12
+      overflow: hidden;
13
+      border-bottom: 2px solid #eee;
14
+      padding: 30px 0;
15
+      > .Title {
18 16
         position: relative;
19 17
         overflow: hidden;
20
-        > .Img {
21
-          padding: 30px 120px;
22
-          > view {
23
-            width: 100%;
24
-            padding-bottom: 120%;
25
-            position: relative;
26
-            overflow: hidden;
27
-            > image {
28
-              width: 100%;
29
-              height: 100%;
30
-            }
31
-          }
32
-        }
33
-        > .SubInfo {
34
-          position: relative;
35
-          overflow: hidden;
36
-          > .Tag {
37
-            font-size: 0;
38
-            white-space: nowrap;
39
-            padding: 0 30px;
40
-            > text {
41
-              display: inline-block;
42
-              vertical-align: middle;
43
-              font-size: 28px;
44
-              font-weight: bold;
45
-              line-height: 60px;
46
-              margin-right: 10px;
47
-              &.iconfont {
48
-                font-weight: normal;
49
-                font-size: 40px;
50
-              }
51
-            }
52
-          }
53
-          > .flex-h {
54
-            align-items: center;
55
-            padding: 0 30px;
56
-            > view {
57
-              align-items: center;
58
-              > text {
59
-                font-size: 28px;
60
-                line-height: 40px;
61
-                white-space: nowrap;
62
-                overflow: hidden;
63
-                text-overflow: ellipsis;
64
-                color: #999;
65
-                &:first-child {
66
-                  margin-right: 10px;
67
-                }
68
-              }
69
-            }
70
-          }
71
-          > .Desc {
72
-            padding: 0 30px;
73
-            position: relative;
74
-            overflow: hidden;
75
-            > text {
76
-              width: 100%;
77
-              display: block;
78
-              font-size: 28px;
79
-              line-height: 40px;
80
-              color: #999;
81
-            }
82
-          }
83
-        }
84
-        > .Article {
85
-          position: relative;
86
-          overflow: hidden;
87
-          border-top: 2px solid #eee;
88
-          padding: 30px;
89
-          margin-top: 30px;
90
-        }
91
-        > .ToAnswer {
92
-          padding: 30px;
93
-          position: relative;
94
-          overflow: hidden;
95
-          > navigator {
96
-            display: block;
97
-            text-align: center;
98
-            font-size: 28px;
99
-            background: #f4c819;
100
-            line-height: 80px;
101
-            border-radius: 40px;
102
-            color: #333;
103
-          }
104
-        }
105
-      }
106
-    }
107
-  }
108
-  > .Bottom {
109
-    position: relative;
110
-    overflow: hidden;
111
-    background: #fff;
112
-    align-items: center;
113
-    padding-left: 30px;
114
-    z-index: 2;
115
-    box-shadow: 0 0 10px 10px rgba(0, 0, 0, 0.05);
116
-    > .Share,
117
-    .Like {
118
-      font-size: 0;
119
-      white-space: nowrap;
120
-      margin-right: 30px;
121
-      > text {
122
-        display: inline-block;
123
-        vertical-align: middle;
124
-        font-size: 28px;
125
-        color: #333;
126
-        line-height: 40px;
127
-        &:first-child {
128
-          font-size: 36px;
129
-          &.active {
130
-            color: #f4c819;
131
-          }
18
+        > text {
19
+          font-size: 28px;
20
+          line-height: 40px;
21
+          display: block;
132 22
         }
133 23
       }
134
-    }
135
-    > .Answer {
136
-      position: relative;
137
-      overflow: hidden;
138
-      > navigator {
139
-        display: block;
140
-        width: 180px;
141
-        text-align: center;
142
-        line-height: 100px;
143
-        background: #f4c819;
144
-        color: #333;
24
+      > checkbox-group {
145 25
         font-size: 28px;
146
-      }
147
-    }
148
-    > .ReadInfo {
149
-      position: relative;
150
-      overflow: hidden;
151
-      > text {
152
-        display: block;
153 26
         white-space: nowrap;
154
-        font-size: 26px;
155
-        color: #333;
156
-        line-height: 32px;
27
+        display: block;
28
+        position: relative;
157 29
         overflow: hidden;
158
-        text-overflow: ellipsis;
159
-        text-align: right;
30
+        > view {
31
+          display: inline-block;
32
+          vertical-align: middle;
33
+        }
160 34
       }
161
-      > .Progress {
162
-        align-items: center;
163
-        margin-top: 10px;
164
-        > .flex-item {
165
-          height: 10px;
166
-          background: rgba(41, 141, 248, 0.5);
167
-          border-radius: 10px;
35
+      > radio-group {
36
+        position: relative;
37
+        overflow: hidden;
38
+        > label {
39
+          display: block;
168 40
           position: relative;
169 41
           overflow: hidden;
170
-          margin-right: 20px;
42
+          font-size: 28px;
43
+          white-space: nowrap;
44
+          margin-top: 20px;
171 45
           > view {
172
-            width: 0;
173
-            height: 100%;
174
-            position: absolute;
175
-            left: 0;
176
-            top: 0;
177
-            background: rgba(41, 141, 248, 1);
46
+            display: inline-block;
47
+            vertical-align: middle;
48
+            font-size: 28px;
178 49
           }
179 50
         }
180
-        > text {
181
-          font-size: 26px;
182
-          color: #333;
183
-          line-height: 32px;
184
-        }
185 51
       }
186 52
     }
187 53
   }
54
+  .Submit {
55
+    padding: 30px;
56
+    position: relative;
57
+    overflow: hidden;
58
+    > text {
59
+      display: block;
60
+      text-align: center;
61
+      font-size: 28px;
62
+      color: #333;
63
+      background: #f4c819;
64
+      line-height: 80px;
65
+      border-radius: 40px;
66
+    }
67
+  }
188 68
 }

+ 1
- 0
src/pages/Index/BookDetail/index.config.js 查看文件

@@ -1,4 +1,5 @@
1 1
 export default {
2 2
   // navigationStyle: 'custom',
3
+  enableShareAppMessage: true,
3 4
   navigationBarTitleText: '详情'
4 5
 }

+ 11
- 1
src/pages/Index/BookDetail/index.vue 查看文件

@@ -62,7 +62,7 @@
62 62
 
63 63
         <!-- 底部 -->
64 64
         <view class="flex-h Bottom">
65
-          <view class="Share">
65
+          <view class="Share" @tap="ShareArticle">
66 66
             <text class="iconfont iconfenxiang"></text>
67 67
             <text>分享</text>
68 68
           </view>
@@ -113,6 +113,13 @@ export default {
113 113
     MainPage,
114 114
     PageBottom
115 115
   },
116
+  onShareAppMessage () {
117
+    return {
118
+      title: this.ArticleInfo.shareSetting === null ? this.ArticleInfo.name : this.ArticleInfo.shareSetting.title,
119
+      imageUrl:this.ArticleInfo.shareSetting === null ? this.ArticleInfo.poster : this.ArticleInfo.shareSetting.imageUrl,
120
+      path: `/pages/Index/BookDetail/index?id=${Taro.getCurrentInstance().router.params.id}`
121
+    }
122
+  },
116 123
   created () {
117 124
   },
118 125
   mounted () {
@@ -138,6 +145,9 @@ export default {
138 145
           }
139 146
         }
140 147
       }
148
+    },
149
+    ShareArticle () { // 分享
150
+
141 151
     },
142 152
     TriggerSave () {
143 153
       if (!this.DataLock && this.ArticleInfo.postId) {

+ 5
- 0
src/store/index/index.js 查看文件

@@ -28,6 +28,11 @@ export default {
28 28
       return new Promise((resolve, reject) => {
29 29
         ToolClass.ToolRequest({ url: Api.GetSearchArticleList.url, method: Api.GetSearchArticleList.method, ...payload, success (res) { resolve(res) }, error (res) { reject(res) } })
30 30
       })
31
+    },
32
+    PostArticleAnswer (context, payload) { // 提交答题结果
33
+      return new Promise((resolve, reject) => {
34
+        ToolClass.ToolRequest({ url: Api.PostArticleAnswer.url, method: Api.PostArticleAnswer.method, ...payload, success (res) { resolve(res) }, error (res) { reject(res) } })
35
+      })
31 36
     }
32 37
   }
33 38
 }

+ 4
- 0
src/util/Api/index.js 查看文件

@@ -66,6 +66,10 @@ const Api = {
66 66
     method: 'get',
67 67
     url: `${prefix}/ma/post-type`
68 68
   },
69
+  PostArticleAnswer: { // 提交答题结果
70
+    method: 'post',
71
+    url: `${prefix}/ma/answer-test`
72
+  },
69 73
   // GetMyBodyCheckList: { // 获取我的体检记录
70 74
   //   method: 'get',
71 75
   //   url: `${prefix}/ma/medical-log`