dingxin 6 years ago
parent
commit
34a7ebc144

+ 3
- 3
VUECODE/smart-property-manage/src/store/modules/community.js View File

@@ -175,9 +175,9 @@ const community = {
175 175
     UserCommunity({ commit }, data) {
176 176
       return new Promise((resolve, reject) => {
177 177
         userCommunity(data).then(response => {
178
-          const data = response.data
179
-          commit('SET_LIST', data)
180
-          resolve()
178
+          // const data = response.data
179
+          // commit('SET_LIST', data)
180
+          resolve(response)
181 181
         }).catch(error => {
182 182
           reject(error)
183 183
         })

+ 16
- 4
VUECODE/smart-property-manage/src/views/login/index.vue View File

@@ -50,7 +50,7 @@
50 50
             <div v-else class="select-community" >
51 51
               <el-select v-model="loginForm.communityId" placeholder="请选择小区">
52 52
                 <el-option
53
-                  v-for="item in communityList"
53
+                  v-for="item in communityArr"
54 54
                   :key="item.id"
55 55
                   :label="item.communityName"
56 56
                   :value="item.id"/>
@@ -99,6 +99,7 @@ export default {
99 99
       isSelectDiv: false,
100 100
       isSelectCommunity: false, // 是否显示 社区选项
101 101
       isLoginButton: false, // 默认按钮为不可点击
102
+      communityArr: [], // 小区集合
102 103
       loginForm: {
103 104
         username: '',
104 105
         password: '',
@@ -142,6 +143,7 @@ export default {
142 143
               // this.$router.push({ path: this.redirect || '/index' })
143 144
               this.$router.push({ name: 'index' })
144 145
             } else {
146
+              this.$message.error(res.message)
145 147
               this.loading = false
146 148
             }
147 149
           }).catch(() => {
@@ -171,6 +173,8 @@ export default {
171 173
             }
172 174
             this.codeNum--
173 175
           }, 1000)
176
+        } else {
177
+          this.$message.error(res.message)
174 178
         }
175 179
       }).catch(() => {
176 180
         console.log('error sendcode')
@@ -183,8 +187,16 @@ export default {
183 187
         spinner: 'el-icon-loading',
184 188
         background: 'rgba(0, 0, 0, 0.7)'
185 189
       })
186
-      this.UserCommunity(this.loginForm).then(() => {
187
-        loading.close()
190
+      this.UserCommunity(this.loginForm).then((res) => {
191
+        if (res.code === '0') {
192
+          this.communityArr = res.data
193
+          this.loading = false
194
+          loading.close()
195
+        } else {
196
+          loading.close()
197
+          this.$message.error(res.message)
198
+          this.loading = false
199
+        }
188 200
         this.checkPhoneAndCode()
189 201
       }).catch(() => {
190 202
         // 提示 当前手机号未绑定任何社区
@@ -200,7 +212,7 @@ export default {
200 212
     },
201 213
     checkPhoneAndCode() { // 失去焦点的时候获取 获取用户的管理的小区
202 214
       console.log('失去焦点')
203
-      const communitys = this.communityList
215
+      const communitys = this.communityArr
204 216
       console.log('接收到的数据:', communitys)
205 217
       console.log('大小:', communitys.length)
206 218
       if (communitys.length === 0) {

+ 41
- 10
VUECODE/smart-property-manage/src/views/social/activity/add/index.vue View File

@@ -103,15 +103,9 @@ export default {
103 103
   },
104 104
   methods: {
105 105
     submitForm(formName) {
106
-      // 加载框
107
-      const loading = this.$loading({
108
-        lock: true,
109
-        text: 'Loading',
110
-        spinner: 'el-icon-loading',
111
-        background: 'rgba(0, 0, 0, 0.7)'
112
-      })
113 106
       this.$refs[formName].validate((valid) => {
114 107
         if (valid) {
108
+<<<<<<< HEAD
115 109
           if (this.ruleForm.activityContent.length <= 0 && this.ruleForm.contentImg.length <= 0) {
116 110
             this.$message.error('活动内容描述 和 活动配图至少要存在一个!')
117 111
             return false
@@ -131,16 +125,25 @@ export default {
131 125
           }).catch(() => {
132 126
             console.log('error AddActivity')
133 127
           })
128
+=======
129
+          this.addActivity(1)
130
+>>>>>>> 811d58fffdd904260ce7cd3cb075fe3a2e992007
134 131
         } else {
135 132
           console.log('error submit!!')
136 133
           return false
137 134
         }
138 135
       })
139
-      // 关闭加载框
140
-      loading.close()
141 136
     },
142 137
     resetForm(formName) {
143
-      this.$refs[formName].resetFields()
138
+      // this.$refs[formName].resetFields()
139
+      this.$refs[formName].validate((valid) => {
140
+        if (valid) {
141
+          this.addActivity(2)
142
+        } else {
143
+          console.log('error submit!!')
144
+          return false
145
+        }
146
+      })
144 147
     },
145 148
     handleAvatarSuccess(res, file) { // 轮播图上传回调
146 149
       this.ruleForm.activityCarouselImg = res.data[0]
@@ -177,6 +180,34 @@ export default {
177 180
     sortHandleChange(value) { // 权重值
178 181
       this.ruleForm.sort = value
179 182
       console.log(value)
183
+    },
184
+    addActivity(status) { // 添加活动
185
+      // 加载框
186
+      const loading = this.$loading({
187
+        lock: true,
188
+        text: 'Loading',
189
+        spinner: 'el-icon-loading',
190
+        background: 'rgba(0, 0, 0, 0.7)'
191
+      })
192
+      if (this.ruleForm.activityContent.length <= 0 && this.ruleForm.contentImg.length <= 0) {
193
+        this.$message.error('活动内容描述 和 活动配图至少要存在一个!')
194
+        return false
195
+      }
196
+      this.ruleForm.status = status // 发布状态  1 是已发布   2 是草稿
197
+      this.$store.dispatch('AddActivity', this.ruleForm).then((res) => {
198
+        if (res.code === '0') {
199
+          this.$message({
200
+            message: res.message,
201
+            type: 'success'
202
+          })
203
+          this.$router.push({ name: 'activity-index' })
204
+          loading.close()
205
+          return
206
+        }
207
+        this.$message.error(res.message)
208
+      }).catch(() => {
209
+        console.log('error AddActivity')
210
+      })
180 211
     }
181 212
   }
182 213
 }

+ 26
- 19
VUECODE/smart-property-manage/src/views/social/activity/edi/index.vue View File

@@ -33,20 +33,29 @@
33 33
           <img :src="dialogImageUrl" width="100%" alt="">
34 34
         </el-dialog>
35 35
       </el-form-item>
36
-      <el-form-item label="报名人数上限" prop="signUpMax">
37
-        <el-input v-model="ruleForm.signUpMax" placeholder="填写0则不限制报名人数"/>
36
+      <el-form-item prop="signUpMax">
37
+        <div style="display: flex;">
38
+          <span style="width: 140px;">报名人数上限</span>
39
+          <el-input v-model="ruleForm.signUpMax" placeholder="填写0则不限制报名人数"/>
40
+        </div>
38 41
       </el-form-item>
39
-      <el-form-item label="报名截止时间" prop="registrationEndTime">
40
-        <el-date-picker
41
-          v-model="ruleForm.registrationEndTime"
42
-          value-format="yyyy-MM-dd"
43
-          type="date"
44
-          placeholder="选择日期"/>
42
+      <el-form-item prop="registrationEndTime">
43
+        <div style="display: flex;">
44
+          <span style="width: 120px;">报名截止时间</span>
45
+          <el-date-picker
46
+            v-model="ruleForm.registrationEndTime"
47
+            value-format="timestamp"
48
+            type="date"
49
+            placeholder="选择日期"/>
50
+        </div>
45 51
       </el-form-item>
46
-      <el-form-item label="权重值" prop="sort">
47
-        <el-input-number v-model="ruleForm.sort" :min="1" :max="10" label="权重值" @change="sortHandleChange"/>
52
+      <el-form-item prop="sort">
53
+        <div style="display: flex; justify-content: flex-start;">
54
+          <span style="width: 120px;">权重值</span>
55
+          <el-input-number v-model="ruleForm.sort" :min="1" :max="10" label="权重值" @change="sortHandleChange"/>
56
+        </div>
48 57
       </el-form-item>
49
-      <el-form-item>
58
+      <el-form-item style="display: flex; justify-content: center;">
50 59
         <el-button @click="resetForm('ruleForm')">存为草稿</el-button>
51 60
         <el-button type="primary" @click="submitForm('ruleForm')">发布</el-button>
52 61
       </el-form-item>
@@ -60,7 +69,6 @@ export default {
60 69
   data() {
61 70
     return {
62 71
       ruleForm: {
63
-        id: '',
64 72
         activityTitle: '',
65 73
         activityCarouselImg: '', // 轮播图
66 74
         activityContent: '', // 活动内容详细
@@ -71,6 +79,8 @@ export default {
71 79
         status: '' // 状态 0 是已作废 1 是已发布   2 是草稿 3 是已修改
72 80
       },
73 81
       imageUrl: '', // 轮播图预览
82
+      dialogVisible: false, // 活动配图, 默认不显示 (以单张为单位)
83
+      dialogImageUrl: '', // 活动配图, 图片链接 (以单张为单位)
74 84
       rules: {
75 85
         activityTitle: [
76 86
           { required: true, message: '请输入活动名称', trigger: 'blur' },
@@ -107,7 +117,7 @@ export default {
107 117
             return false
108 118
           }
109 119
           this.ruleForm.status = 1 // 发布状态
110
-          this.$store.dispatch('UpdateActivity', this.ruleForm).then((res) => {
120
+          this.$store.dispatch('AddActivity', this.ruleForm).then((res) => {
111 121
             if (res.code === '0') {
112 122
               this.$message({
113 123
                 message: res.message,
@@ -118,16 +128,16 @@ export default {
118 128
               return
119 129
             }
120 130
             this.$message.error(res.message)
121
-            loading.close()
122 131
           }).catch(() => {
123
-            console.log('error UpdateActivity')
132
+            console.log('error AddActivity')
124 133
           })
125 134
         } else {
126 135
           console.log('error submit!!')
127
-          loading.close()
128 136
           return false
129 137
         }
130 138
       })
139
+      // 关闭加载框
140
+      loading.close()
131 141
     },
132 142
     resetForm(formName) {
133 143
       this.$refs[formName].resetFields()
@@ -167,9 +177,6 @@ export default {
167 177
     sortHandleChange(value) { // 权重值
168 178
       this.ruleForm.sort = value
169 179
       console.log(value)
170
-    },
171
-    getById() { // 根据 id 查询活动详情
172
-
173 180
     }
174 181
   }
175 182
 }