许成详 6 years ago
parent
commit
cbeb6f2093

+ 56
- 0
src/common/css/reset.css View File

@@ -85,4 +85,60 @@ select option {
85 85
 
86 86
 .van-dialog__message .van-dialog__message--has-title{
87 87
 	text-align: center;
88
+}
89
+
90
+.dialogContent{
91
+	padding: 0 .15rem;
92
+}
93
+
94
+.dialogContent>.title{
95
+	width: 100%;
96
+	text-align: center;
97
+	display: block;
98
+	line-height: .26rem;
99
+	font-size: .16rem;
100
+	margin: .15rem auto 0;
101
+}
102
+
103
+.dialogContent>div{
104
+	width: 100%;
105
+	position: relative;
106
+	overflow: hidden;
107
+	margin: .15rem auto 0;
108
+}
109
+
110
+.dialogContent .btn{
111
+	width: 100%;
112
+	position: relative;
113
+	overflow: hidden;
114
+	margin-bottom: .2rem;
115
+	white-space: nowrap;
116
+	font-size: 0;
117
+	text-align: center;
118
+}
119
+
120
+.dialogContent>.btn>a{
121
+	width: 1rem;
122
+	display: inline-block;
123
+	line-height: .36rem;
124
+	border-radius: .05rem;
125
+	text-align: center;
126
+	border: 1px solid #787878;
127
+	margin-left: .2rem;
128
+}
129
+
130
+.dialogContent>.btn>a:first-child{
131
+	margin-left: 0;
132
+	background: #fc6243;
133
+	color: #fff;
134
+	border: 1px solid #fc6243;
135
+}
136
+
137
+.dialogContent>.btn>a:only-child{
138
+	width: 1.6rem;
139
+	display: block;
140
+	margin:  0 auto;
141
+	background: #fc6243;
142
+	color: #fff;
143
+	border: 1px solid #fc6243;
88 144
 }

+ 113
- 0
src/components/libraryListItem/index.vue View File

@@ -0,0 +1,113 @@
1
+<template>
2
+  <div class="libraryListItem flex-h">
3
+    <div class="img">
4
+      <a>
5
+        <img :src="data.img" class="centerLabel cover" alt>
6
+      </a>
7
+    </div>
8
+    <div class="flex-item">
9
+      <div>
10
+        <span>{{data.name}}</span>
11
+        <div class="flex-h" style="margin-top: .06rem;">
12
+          <span class="flex-item">{{data.author}} 著</span>
13
+          <span class="status" @click="appointmentBook(data.id)">{{data.status}}</span>
14
+        </div>
15
+        <div class="flex-h">
16
+          <span class="flex-item">{{data.publishingHouses}}</span>
17
+          <span>剩余可借
18
+            <em>{{data.stock}}</em>本
19
+          </span>
20
+        </div>
21
+      </div>
22
+    </div>
23
+  </div>
24
+</template>
25
+
26
+<script>
27
+
28
+export default {
29
+  name: '',
30
+  props: ['data'],
31
+  data () {
32
+    return {
33
+    }
34
+  },
35
+  computed: {
36
+  },
37
+  components: {
38
+  },
39
+  created () {
40
+  },
41
+  methods: {
42
+    appointmentBook (id) {
43
+      this.$emit('appointmentBook', id)
44
+    }
45
+  }
46
+}
47
+</script>
48
+
49
+<!-- Add "scoped" attribute to limit CSS to this component only -->
50
+<style lang="scss" scoped>
51
+.libraryListItem {
52
+  width: 100%;
53
+  position: relative;
54
+  overflow: hidden;
55
+  align-items: center;
56
+  .img {
57
+    width: 0.78rem;
58
+    position: relative;
59
+    overflow: hidden;
60
+    a {
61
+      width: 100%;
62
+      display: block;
63
+      height: 0;
64
+      position: relative;
65
+      overflow: hidden;
66
+      padding-bottom: 143.5%;
67
+      background: #eee;
68
+      border-radius: 0.03rem;
69
+    }
70
+  }
71
+  > div.flex-item {
72
+    margin-left: 0.1rem;
73
+    > div {
74
+      width: 100%;
75
+      position: relative;
76
+      overflow: hidden;
77
+      > span {
78
+        width: 100%;
79
+        display: block;
80
+        line-height: 0.22rem;
81
+        font-size: 0.16rem;
82
+        overflow: hidden;
83
+        text-overflow: ellipsis;
84
+        display: -webkit-box;
85
+        -webkit-box-orient: vertical;
86
+        -webkit-line-clamp: 2;
87
+        max-height: 0.43rem;
88
+      }
89
+      > div {
90
+        margin-top: 0.03rem;
91
+        align-items: center;
92
+        span {
93
+          line-height: 0.25rem;
94
+          font-size: 0.12rem;
95
+          color: #999;
96
+          white-space: nowrap;
97
+          em {
98
+            color: #fc5534;
99
+            font-size: 0.13rem;
100
+          }
101
+          &.status {
102
+            padding: 0 0.15rem;
103
+            font-size: 0.12rem;
104
+            color: #fc674a;
105
+            background: #fcf3f3;
106
+            border-radius: 0.25rem;
107
+          }
108
+        }
109
+      }
110
+    }
111
+  }
112
+}
113
+</style>

+ 68
- 0
src/components/radio/index.vue View File

@@ -0,0 +1,68 @@
1
+<template>
2
+  <div class="radio">
3
+    <a v-for="(item,index) in data" :key="index" :class="{'active': item.id === value}" @click="cut(item)">{{item.value}}</a>
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+export default {
9
+  name: '',
10
+  props: ['data', 'value', 'disabled'],
11
+  data () {
12
+    return {
13
+    }
14
+  },
15
+  created () {
16
+  },
17
+  methods: {
18
+    cut (item) {
19
+      if (!this.disabled) {
20
+        this.$emit('input', item.id)
21
+      }
22
+    }
23
+  }
24
+}
25
+</script>
26
+
27
+<!-- Add "scoped" attribute to limit CSS to this component only -->
28
+<style lang="scss" scoped>
29
+.radio {
30
+  font-size: 0;
31
+  white-space: nowrap;
32
+  > * {
33
+    display: block;
34
+    font-size: 0.15rem;
35
+    position: relative;
36
+    padding-left: 0.25rem;
37
+    color: #a1a1a1;
38
+    margin-left: 0.5rem;
39
+    line-height: .3rem;
40
+    &::after {
41
+      content: "";
42
+      width: 0.14rem;
43
+      height: 0.14rem;
44
+      position: absolute;
45
+      left: 0;
46
+      top: 50%;
47
+      transform: translateY(-50%);
48
+      -webkit-transform: translateY(-50%);
49
+      border-radius: 100%;
50
+      border: 0.01rem solid #fc6243;
51
+      z-index: 1;
52
+    }
53
+    &.active::before {
54
+      content: "";
55
+      width: 0.08rem;
56
+      height: 0.08rem;
57
+      position: absolute;
58
+      left: 0.04rem;
59
+      top: 50%;
60
+      transform: translateY(-50%);
61
+      -webkit-transform: translateY(-50%);
62
+      border-radius: 100%;
63
+      background: #fc6243;
64
+      z-index: 2;
65
+    }
66
+  }
67
+}
68
+</style>

+ 83
- 0
src/pages/user/library/navList/index.vue View File

@@ -0,0 +1,83 @@
1
+<template>
2
+  <div class="mainPage">
3
+    <div>
4
+      <nav class="nav">
5
+        <a v-for="(item, index) in navList" :key="index" @click="navClick(item)">
6
+          <img :src="item.icon" alt>
7
+          <span>{{item.name}}</span>
8
+        </a>
9
+      </nav>
10
+    </div>
11
+  </div>
12
+</template>
13
+
14
+<script>
15
+import { mapState, createNamespacedHelpers } from 'vuex'
16
+const { mapActions: mapAppActions } = createNamespacedHelpers('app')
17
+const { mapState: mapLibraryState, mapActions: mapLibraryAction } = createNamespacedHelpers('library')
18
+export default {
19
+  data () {
20
+    return {
21
+    }
22
+  },
23
+  created () {
24
+  },
25
+  computed: {
26
+    ...mapState({
27
+      CaseList: x => x.app.CaseList,
28
+    }),
29
+    ...mapLibraryState({
30
+      navList: x => x.navList
31
+    })
32
+  },
33
+  components: {
34
+  },
35
+  methods: {
36
+    ...mapAppActions([
37
+      'getCaseList',
38
+    ]),
39
+    ...mapLibraryAction(['getNavList']),
40
+    navClick (item) {
41
+    }
42
+  }
43
+}
44
+</script>
45
+
46
+<style lang="scss" scoped>
47
+.mainPage {
48
+  > div {
49
+    width: 100%;
50
+    position: absolute;
51
+    left: 0;
52
+    top: 0;
53
+    bottom: 0;
54
+    overflow-y: scroll;
55
+    -webkit-overflow-scrolling: touch;
56
+    transform: translateZ(0);
57
+    -webkit-transform: translateZ(0);
58
+    .nav {
59
+      width: 100%;
60
+      position: relative;
61
+      overflow: hidden;
62
+      font-size: 0;
63
+      > a {
64
+        display: inline-block;
65
+        width: 25%;
66
+        text-align: center;
67
+        margin-top: 0.15rem;
68
+        img {
69
+          height: 0.48rem;
70
+        }
71
+        span {
72
+          width: 100%;
73
+          display: inline-block;
74
+          text-align: center;
75
+          font-size: 0.12rem;
76
+          line-height: 0.22rem;
77
+          margin: 0.08rem auto 0;
78
+        }
79
+      }
80
+    }
81
+  }
82
+}
83
+</style>

+ 115
- 6
src/pages/user/mainPage/libraryIndex/index.vue View File

@@ -2,35 +2,144 @@
2 2
   <div class="mainPage">
3 3
     <div>
4 4
       <div class="header flex-h">
5
-        <div class="flex-item">
6
-          <div>
7
-            <i class="iconfont icon-sousuo"></i>
8
-            <input type="text">
5
+        <div class="flex-item flex-h">
6
+          <i class="iconfont icon-sousuo"></i>
7
+          <div class="flex-item">
8
+            <div>
9
+              <input type="text">
10
+            </div>
9 11
           </div>
10 12
         </div>
11
-        <a>
13
+        <a @click="showDialog = true">
12 14
           <i class="iconfont icon-dingwei"></i>
13
-          <span>云台天境</span>
15
+          <span>{{currentCaseName}}</span>
16
+        </a>
17
+      </div>
18
+      <nav class="nav">
19
+        <a v-for="(item, index) in navList" :key="index" @click="navClick(item)">
20
+          <img :src="item.icon" alt>
21
+          <span>{{item.name}}</span>
14 22
         </a>
23
+      </nav>
24
+      <div class="list">
25
+        <h1>精选推荐</h1>
26
+        <ul>
27
+          <li v-for="(item, index) in bookList" :key="index">
28
+            <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
29
+          </li>
30
+        </ul>
15 31
       </div>
32
+      <van-dialog v-model="showDialog" :show-confirm-button="false">
33
+        <div class="dialogContent">
34
+          <span class="title">选择案场</span>
35
+          <div>
36
+            <radio :data="cases" v-model="caseId"></radio>
37
+          </div>
38
+          <div class="btn">
39
+            <a @click="selectCaseId">确定</a>
40
+          </div>
41
+        </div>
42
+      </van-dialog>
43
+      <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
44
+        <div class="dialogContent">
45
+          <span class="title">确认在线预约当前图书?</span>
46
+          <div>
47
+            <span style="color: #666;">在线预约需在2018年12月20日前前往案场借阅图书, 否则 将取消预约资格</span>
48
+          </div>
49
+          <div class="btn">
50
+            <a @click="sureAppointmentBook">确定</a>
51
+            <a @click="showAppointmentDialog = false">取消</a>
52
+          </div>
53
+        </div>
54
+      </van-dialog>
16 55
     </div>
17 56
   </div>
18 57
 </template>
19 58
 
20 59
 <script>
60
+import libraryListItem from '../../../../components/libraryListItem/index'
61
+import radio from '../../../../components/radio/index'
62
+import { mapState, createNamespacedHelpers } from 'vuex'
63
+const { mapActions: mapAppActions } = createNamespacedHelpers('app')
64
+const { mapState: mapLibraryState, mapActions: mapLibraryActions, mapMutations: mapLibraryMutations } = createNamespacedHelpers('library')
21 65
 export default {
22 66
   name: '',
23 67
   data () {
24 68
     return {
69
+      showDialog: false,
70
+      showAppointmentDialog: false,
71
+      caseId: '',
72
+      currentCaseId: '',
73
+      currentCaseName: '',
74
+      cases: []
25 75
     }
26 76
   },
27 77
   computed: {
78
+    ...mapState({
79
+      userInfo: x => x.userCenter.userInfo,
80
+      CaseList: x => x.app.CaseList
81
+    }),
82
+    ...mapLibraryState({
83
+      navList: x => x.navList,
84
+      bookList: x => x.bookList
85
+    }),
28 86
   },
29 87
   components: {
88
+    libraryListItem,
89
+    radio
30 90
   },
31 91
   created () {
92
+    if (!this.CaseList.length || this.CaseList === null) {
93
+      this.getCaseList().then((res) => {
94
+        (res.cases || []).map((item) => {
95
+          this.cases.push({
96
+            value: item.CaseName,
97
+            id: item.CaseId
98
+          })
99
+        })
100
+      })
101
+    } else {
102
+      (this.CaseList || []).map((item) => {
103
+        this.cases.push({
104
+          value: item.CaseName,
105
+          id: item.CaseId
106
+        })
107
+      })
108
+    }
32 109
   },
33 110
   methods: {
111
+    ...mapAppActions(['getCaseList']),
112
+    ...mapLibraryActions(['getNavList', 'getRecommendBookList']),
113
+    ...mapLibraryMutations(['emptyNavInfo', 'emptyRecommendBookList']),
114
+    selectCaseId () { // 选择案场
115
+      if (this.currentCaseId !== this.caseId) {
116
+        this.currentCaseId = this.caseId
117
+        this.CaseList.map((item) => {
118
+          if (item.CaseId === this.currentCaseId) this.currentCaseName = item.CaseName
119
+        })
120
+        this.emptyNavInfo() // 清空nav
121
+        this.getNavList() // 获取nav
122
+        this.emptyRecommendBookList() // 清空精选推荐书籍列表
123
+        this.getRecommendBookList() // 获取精选推荐书籍列表
124
+      }
125
+      this.showDialog = false
126
+    },
127
+    init () { // 初始化
128
+
129
+    },
130
+    appointmentBook () { // 预约图书
131
+      this.showAppointmentDialog = true
132
+    },
133
+    sureAppointmentBook () { // 确定预约图书
134
+      this.showAppointmentDialog = false
135
+    },
136
+    navClick (item) { // 点击nav
137
+      if (item.id === 'more') {
138
+        this.$router.push({ name: 'libraryNavList' })
139
+      } else {
140
+        this.$router.push({ name: 'libraryNavList', query: { id: item.id } })
141
+      }
142
+    }
34 143
   }
35 144
 }
36 145
 </script>

+ 68
- 17
src/pages/user/mainPage/libraryIndex/page.scss View File

@@ -15,34 +15,85 @@
15 15
       padding: .1rem 0;
16 16
       >div{
17 17
         margin: 0 .1rem 0 .2rem;
18
+        background: #f2f2f2;
19
+        align-items: center;
20
+        i{
21
+          font-size: .15rem;
22
+          color: #ccc;
23
+          margin-left: .08rem;
24
+        }
18 25
         >div{
19
-          width: 100%;
20
-          position: relative;
21
-          overflow: hidden;
22
-          font-size: 0;
23
-          white-space: nowrap;
24
-          background: #f2f2f2;
25
-          padding: .05rem 0;
26
+          margin-left: .05rem;
26 27
           >*{
27 28
             display: inline-block;
28 29
             vertical-align: middle;
29 30
             line-height: .2rem;
30 31
           }
31
-          i{
32
-            font-size: .15rem;
33
-            color: #ccc;
34
-            margin-left: .08rem;
35
-          }
36
-          input{
37
-            font-size: .13rem;
38
-            color: #ccc;
39
-            margin-left: .05rem;
40
-            background: none;
32
+          >div{
33
+            width: 100%;
34
+            position: relative;
35
+            overflow: hidden;
36
+            input{
37
+              width: 100%;
38
+              font-size: .13rem;
39
+              color: #ccc;
40
+              background: none;
41
+              padding: .05rem 0;
42
+            }
41 43
           }
42 44
         }
43 45
       }
44 46
       >a{
45 47
         margin-right: .2rem;
48
+        font-size: 0;
49
+        white-space: nowrap;
50
+        >*{
51
+          display: inline-block;
52
+          vertical-align: middle;
53
+        }
54
+      }
55
+    }
56
+    .nav{
57
+      width: 100%;
58
+      position: relative;
59
+      overflow: hidden;
60
+      font-size: 0;
61
+      >a{
62
+        display: inline-block;
63
+        width: 25%;
64
+        text-align: center;
65
+        margin-top: .15rem;
66
+        img{
67
+          height: .48rem;
68
+        }
69
+        span{
70
+          width: 100%;
71
+          display: inline-block;
72
+          text-align: center;
73
+          font-size: .12rem;
74
+          line-height: .22rem;
75
+          margin: .08rem auto 0;
76
+        }
77
+      }
78
+    }
79
+    .list{
80
+      padding: 0 .16rem;
81
+      margin: .32rem auto 0;
82
+      >h1{
83
+        line-height: .28rem;
84
+        font-size: .17rem;
85
+      }
86
+      >ul{
87
+        width: 100%;
88
+        position: relative;
89
+        overflow: hidden;
90
+        margin: .1rem auto .2rem;
91
+        >li{
92
+          width: 100%;
93
+          position: relative;
94
+          overflow: hidden;
95
+          margin: .1rem auto 0;
96
+        }
46 97
       }
47 98
     }
48 99
   }

+ 6
- 0
src/pages/user/router.js View File

@@ -14,6 +14,7 @@ import placeOrderDetail from './placeOrderDetail/index' // 城咖啡-点单详
14 14
 import orderList from './orderList/index' // 城咖啡-点单列表
15 15
 import libraryIndex from './mainPage/libraryIndex/index' // 图书馆首页
16 16
 import userCenter from './mainPage/userCenter/index' // 个人中心
17
+import libraryNavList from './library/navList/index' // 图书馆nav
17 18
 import bindMobile from './bindMobile/bindMobile' // 绑定手机号
18 19
 import lessonOrder from './lessonOrder/index' // 我的订单
19 20
 import vip from './vip/index' // vip卡说明
@@ -65,6 +66,11 @@ const router = new Router({
65 66
       component: userCenter,
66 67
       children: []
67 68
     }]
69
+  }, { // 图书馆nav
70
+    path: '/libraryNavList',
71
+    name: 'libraryNavList',
72
+    component: libraryNavList,
73
+    children: []
68 74
   }, { // 城咖啡-点单
69 75
     path: '/placeOrder',
70 76
     name: 'placeOrder',

+ 1
- 0
src/store/index.js View File

@@ -30,6 +30,7 @@ export const modules = {
30 30
   rush: () => require('./rush/index').default,
31 31
   making: () => require('./making/index').default,
32 32
   customization: () => require('./customization/index').default,
33
+  library: () => require('./library/index').default,
33 34
 }
34 35
 
35 36
 Object.keys(modules).forEach((modKey) => {

+ 138
- 0
src/store/library/index.js View File

@@ -0,0 +1,138 @@
1
+import Ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    navList: [{
8
+      icon: '',
9
+      name: '名著',
10
+      id: ''
11
+    }, {
12
+      icon: '',
13
+      name: '文学',
14
+      id: ''
15
+    }, {
16
+      icon: '',
17
+      name: '历史',
18
+      id: ''
19
+    }, {
20
+      icon: '',
21
+      name: '学术',
22
+      id: ''
23
+    }, {
24
+      icon: '',
25
+      name: '童话',
26
+      id: ''
27
+    }, {
28
+      icon: '',
29
+      name: '天文',
30
+      id: ''
31
+    }, {
32
+      icon: '',
33
+      name: '期刊',
34
+      id: ''
35
+    }, {
36
+      icon: '',
37
+      name: '更多',
38
+      id: 'more'
39
+    }],
40
+    bookList: [{
41
+      img: '',
42
+      name: '书名',
43
+      id: '',
44
+      status: '状态',
45
+      author: '作者',
46
+      publishingHouses: '出版社',
47
+      stock: '10'
48
+    }, {
49
+      img: '',
50
+      name: '书名',
51
+      id: '',
52
+      status: '状态',
53
+      author: '作者',
54
+      publishingHouses: '出版社',
55
+      stock: '10'
56
+    }, {
57
+      img: '',
58
+      name: '书名',
59
+      id: '',
60
+      status: '状态',
61
+      author: '作者',
62
+      publishingHouses: '出版社',
63
+      stock: '10'
64
+    }, {
65
+      img: '',
66
+      name: '书名',
67
+      id: '',
68
+      status: '状态',
69
+      author: '作者',
70
+      publishingHouses: '出版社',
71
+      stock: '10'
72
+    }, {
73
+      img: '',
74
+      name: '书名',
75
+      id: '',
76
+      status: '状态',
77
+      author: '作者',
78
+      publishingHouses: '出版社',
79
+      stock: '10'
80
+    }]
81
+  },
82
+  mutations: {
83
+    setNavInfo (state, data) { // 赋值nav
84
+      (data || []).map((item) => {
85
+        state.navList.push({
86
+          icon: '',
87
+          name: '历史',
88
+          id: ''
89
+        })
90
+      })
91
+    },
92
+    emptyNavInfo (state, data) { // 清空nav
93
+      state.navList = []
94
+    },
95
+    setRecommendBookList (state, data) { // 赋值精选推荐书籍列表
96
+      (data || []).map((item) => {
97
+        state.bookList.push({
98
+          img: '',
99
+          name: '书名',
100
+          id: '',
101
+          status: '状态',
102
+          author: '作者',
103
+          publishingHouses: '出版社',
104
+          stock: '10'
105
+        })
106
+      })
107
+    },
108
+    emptyRecommendBookList (state, data) { // 清空精选推荐书籍列表
109
+      state.bookList = []
110
+    }
111
+  },
112
+  actions: {
113
+    getNavList (context, data) { // 获取nav数据
114
+      return new Promise((resolve, reject) => {
115
+        Ajax(api.library.getNavList.url, {
116
+          method: api.library.getNavList.method
117
+        }).then(res => {
118
+          context.commit('setNavInfo', res)
119
+          resolve(res)
120
+        }).catch((err) => {
121
+          reject(err)
122
+        })
123
+      })
124
+    },
125
+    getRecommendBookList (context, data) { // 获取精选推荐书籍列表
126
+      return new Promise((resolve, reject) => {
127
+        Ajax(api.library.getRecommendBookList.url, {
128
+          method: api.library.getRecommendBookList.method
129
+        }).then(res => {
130
+          context.commit('setRecommendBookList', res)
131
+          resolve(res)
132
+        }).catch((err) => {
133
+          reject(err)
134
+        })
135
+      })
136
+    }
137
+  }
138
+}

+ 10
- 0
src/util/api.js View File

@@ -332,6 +332,16 @@ const $api = {
332 332
       method: 'get',
333 333
       url: `${baseUrl}${wechat}/calendar/isattend/customer`
334 334
     }
335
+  },
336
+  library: {
337
+    getNavList: { // 获取图书馆nav
338
+      method: 'get',
339
+      url: `${baseUrl}${wechat}/`
340
+    },
341
+    getRecommendBookList: { // 获取精选推荐书籍列表
342
+      method: 'get',
343
+      url: `${baseUrl}${wechat}/`
344
+    }
335 345
   }
336 346
 }
337 347
 export default $api