dingxin 6 years ago
parent
commit
34a7ebc144

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

175
     UserCommunity({ commit }, data) {
175
     UserCommunity({ commit }, data) {
176
       return new Promise((resolve, reject) => {
176
       return new Promise((resolve, reject) => {
177
         userCommunity(data).then(response => {
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
         }).catch(error => {
181
         }).catch(error => {
182
           reject(error)
182
           reject(error)
183
         })
183
         })

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

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

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

103
   },
103
   },
104
   methods: {
104
   methods: {
105
     submitForm(formName) {
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
       this.$refs[formName].validate((valid) => {
106
       this.$refs[formName].validate((valid) => {
114
         if (valid) {
107
         if (valid) {
108
+<<<<<<< HEAD
115
           if (this.ruleForm.activityContent.length <= 0 && this.ruleForm.contentImg.length <= 0) {
109
           if (this.ruleForm.activityContent.length <= 0 && this.ruleForm.contentImg.length <= 0) {
116
             this.$message.error('活动内容描述 和 活动配图至少要存在一个!')
110
             this.$message.error('活动内容描述 和 活动配图至少要存在一个!')
117
             return false
111
             return false
131
           }).catch(() => {
125
           }).catch(() => {
132
             console.log('error AddActivity')
126
             console.log('error AddActivity')
133
           })
127
           })
128
+=======
129
+          this.addActivity(1)
130
+>>>>>>> 811d58fffdd904260ce7cd3cb075fe3a2e992007
134
         } else {
131
         } else {
135
           console.log('error submit!!')
132
           console.log('error submit!!')
136
           return false
133
           return false
137
         }
134
         }
138
       })
135
       })
139
-      // 关闭加载框
140
-      loading.close()
141
     },
136
     },
142
     resetForm(formName) {
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
     handleAvatarSuccess(res, file) { // 轮播图上传回调
148
     handleAvatarSuccess(res, file) { // 轮播图上传回调
146
       this.ruleForm.activityCarouselImg = res.data[0]
149
       this.ruleForm.activityCarouselImg = res.data[0]
177
     sortHandleChange(value) { // 权重值
180
     sortHandleChange(value) { // 权重值
178
       this.ruleForm.sort = value
181
       this.ruleForm.sort = value
179
       console.log(value)
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
           <img :src="dialogImageUrl" width="100%" alt="">
33
           <img :src="dialogImageUrl" width="100%" alt="">
34
         </el-dialog>
34
         </el-dialog>
35
       </el-form-item>
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
       </el-form-item>
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
       </el-form-item>
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
       </el-form-item>
57
       </el-form-item>
49
-      <el-form-item>
58
+      <el-form-item style="display: flex; justify-content: center;">
50
         <el-button @click="resetForm('ruleForm')">存为草稿</el-button>
59
         <el-button @click="resetForm('ruleForm')">存为草稿</el-button>
51
         <el-button type="primary" @click="submitForm('ruleForm')">发布</el-button>
60
         <el-button type="primary" @click="submitForm('ruleForm')">发布</el-button>
52
       </el-form-item>
61
       </el-form-item>
60
   data() {
69
   data() {
61
     return {
70
     return {
62
       ruleForm: {
71
       ruleForm: {
63
-        id: '',
64
         activityTitle: '',
72
         activityTitle: '',
65
         activityCarouselImg: '', // 轮播图
73
         activityCarouselImg: '', // 轮播图
66
         activityContent: '', // 活动内容详细
74
         activityContent: '', // 活动内容详细
71
         status: '' // 状态 0 是已作废 1 是已发布   2 是草稿 3 是已修改
79
         status: '' // 状态 0 是已作废 1 是已发布   2 是草稿 3 是已修改
72
       },
80
       },
73
       imageUrl: '', // 轮播图预览
81
       imageUrl: '', // 轮播图预览
82
+      dialogVisible: false, // 活动配图, 默认不显示 (以单张为单位)
83
+      dialogImageUrl: '', // 活动配图, 图片链接 (以单张为单位)
74
       rules: {
84
       rules: {
75
         activityTitle: [
85
         activityTitle: [
76
           { required: true, message: '请输入活动名称', trigger: 'blur' },
86
           { required: true, message: '请输入活动名称', trigger: 'blur' },
107
             return false
117
             return false
108
           }
118
           }
109
           this.ruleForm.status = 1 // 发布状态
119
           this.ruleForm.status = 1 // 发布状态
110
-          this.$store.dispatch('UpdateActivity', this.ruleForm).then((res) => {
120
+          this.$store.dispatch('AddActivity', this.ruleForm).then((res) => {
111
             if (res.code === '0') {
121
             if (res.code === '0') {
112
               this.$message({
122
               this.$message({
113
                 message: res.message,
123
                 message: res.message,
118
               return
128
               return
119
             }
129
             }
120
             this.$message.error(res.message)
130
             this.$message.error(res.message)
121
-            loading.close()
122
           }).catch(() => {
131
           }).catch(() => {
123
-            console.log('error UpdateActivity')
132
+            console.log('error AddActivity')
124
           })
133
           })
125
         } else {
134
         } else {
126
           console.log('error submit!!')
135
           console.log('error submit!!')
127
-          loading.close()
128
           return false
136
           return false
129
         }
137
         }
130
       })
138
       })
139
+      // 关闭加载框
140
+      loading.close()
131
     },
141
     },
132
     resetForm(formName) {
142
     resetForm(formName) {
133
       this.$refs[formName].resetFields()
143
       this.$refs[formName].resetFields()
167
     sortHandleChange(value) { // 权重值
177
     sortHandleChange(value) { // 权重值
168
       this.ruleForm.sort = value
178
       this.ruleForm.sort = value
169
       console.log(value)
179
       console.log(value)
170
-    },
171
-    getById() { // 根据 id 查询活动详情
172
-
173
     }
180
     }
174
   }
181
   }
175
 }
182
 }