main.js 13.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
global.webpackJsonp([10],{

/***/ 308:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _vue = __webpack_require__(1);

var _vue2 = _interopRequireDefault(_vue);

var _index = __webpack_require__(309);

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var app = new _vue2.default(_index2.default);
app.$mount();

/***/ }),

/***/ 309:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_mpvue_loader_lib_selector_type_script_index_0_index_vue__ = __webpack_require__(311);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_mpvue_loader_lib_selector_type_script_index_0_index_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_mpvue_loader_lib_selector_type_script_index_0_index_vue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_mpvue_loader_lib_template_compiler_index_id_data_v_244d919a_hasScoped_true_transformToRequire_video_src_source_src_img_src_image_xlink_href_node_modules_mpvue_loader_lib_selector_type_template_index_0_index_vue__ = __webpack_require__(312);
var disposed = false
function injectStyle (ssrContext) {
  if (disposed) return
  __webpack_require__(310)
}
var normalizeComponent = __webpack_require__(0)
/* script */

/* template */

/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-244d919a"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
  __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_mpvue_loader_lib_selector_type_script_index_0_index_vue___default.a,
  __WEBPACK_IMPORTED_MODULE_1__node_modules_mpvue_loader_lib_template_compiler_index_id_data_v_244d919a_hasScoped_true_transformToRequire_video_src_source_src_img_src_image_xlink_href_node_modules_mpvue_loader_lib_selector_type_template_index_0_index_vue__["a" /* default */],
  __vue_styles__,
  __vue_scopeId__,
  __vue_module_identifier__
)
Component.options.__file = "src\\pages\\releaseArticle\\index.vue"
if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key.substr(0, 2) !== "__"})) {console.error("named exports are not supported in *.vue files.")}
if (Component.options.functional) {console.error("[vue-loader] index.vue: functional components are not supported with templates, they should use render functions.")}

/* hot reload */
if (false) {(function () {
  var hotAPI = require("vue-hot-reload-api")
  hotAPI.install(require("vue"), false)
  if (!hotAPI.compatible) return
  module.hot.accept()
  if (!module.hot.data) {
    hotAPI.createRecord("data-v-244d919a", Component.options)
  } else {
    hotAPI.reload("data-v-244d919a", Component.options)
  }
  module.hot.dispose(function (data) {
    disposed = true
  })
})()}

/* harmony default export */ __webpack_exports__["default"] = (Component.exports);


/***/ }),

/***/ 310:
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ }),

/***/ 311:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

exports.default = {
  data: function data() {
    return {
      sort: ['婚姻家庭', '交通事故', '刑事辩护', '劳动工伤', '房产纠纷', '债权债务', '合同事务', '医疗纠纷', '知识产权', '损害赔偿', '征地拆迁', '其它'],
      selectedTags: [],
      styleTags: [],
      imgs: ['', '', '', '', '', '', '', '', '', '', '', ''],
      classes: ['p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p11'],
      text: '',
      imgfiles: [],
      title: '',
      canIclear: false,
      type: ''
    };
  },

  methods: {
    cancelImg: function cancelImg(i) {
      var _this = this;

      wx.showModal({
        title: '',
        content: '放弃上传这张照片吗?',
        success: function success(res) {
          if (res.confirm) {
            _this.imgfiles.splice(i, 1);
          }
        }
      });
    },
    previewImg: function previewImg(i) {
      wx.previewImage({
        urls: this.imgfiles,
        current: this.imgfiles[i]
      });
    },
    selectTags: function selectTags(i) {
      if (this.selectedTags.indexOf(i) > -1) {
        //我点击的类型已经被选择
        this.selectedTags.splice(this.selectedTags.indexOf(i), 1); //删除该类型的选择态(从已选择列表中移除)
        this.styleTags[i] = this.imgs[i] = ''; //删除该类型的选择态(去除背景色样式,切换图片)
      } else if (this.selectedTags.length < 3) {
        //我点击的类型没有被选择且当前已选择数目小于3
        this.selectedTags.push(i); //激活该类型的选择态(添加到已选择列表)
        this.styleTags[i] = 'background:#AA001A;color:white;'; //添加背景色样式
        this.imgs[i] = '_select'; //切换图片
      }
    },
    commit: function commit() {
      var _this2 = this;

      var errTitle = '提交失败';
      if (this.title == '') {
        if (!wx.showModal({
          title: errTitle,
          content: '标题不能为空',
          showCancel: false,
          success: function success(res) {
            if (res.confirm) return false;
          }
        })) return;
      }
      if (this.selectedTags.length == 0) {
        if (!wx.showModal({
          title: errTitle,
          content: '类别不能为空',
          showCancel: false,
          success: function success(res) {
            if (res.confirm) return false;
          }
        })) return;
      }
      if (this.text == '') {
        if (!wx.showModal({
          title: errTitle,
          content: '正文不能为空',
          showCancel: false,
          success: function success(res) {
            if (res.confirm) return false;
          }
        })) return;
      }
      wx.showLoading({ title: '正在上传文本' });
      wx.request({
        url: this.rootUrl + '/pub/addpub',
        method: 'POST',
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        data: {
          Info_Title: this.title,
          Info_Content: this.text,
          Info_Tag: this.selectedTags.map(function (v) {
            return ++v;
          }).join('.'),
          Info_Type: this.type,
          sessionID: wx.getStorageSync('sessionID')
        },
        success: function success(res) {
          if (res.statusCode == '500') {
            _this2.service.getUnionId(_this2.rootAvatar, _this2.rootUrl).then(function (res) {
              console.log(res);
              _this2.commit();
            });
          } else {
            if (_this2.imgfiles.length > 0) {
              _this2.upLoadImgs(res.data);
            } else if (res.data == 1) {
              wx.hideLoading();
              wx.navigateBack({ delta: 1 });
              _this2.canIclear = true;
              console.log(res);
            }
          }
        },
        fail: function fail(res) {
          console.log(res);
        }
      });
    },
    upLoadImgs: function upLoadImgs(CWXID) {
      var _this3 = this;

      wx.showLoading({ title: '正在上传图片' });
      var time = this.imgfiles.length;
      var counter = time;

      var _loop = function _loop(i) {
        wx.uploadFile({
          url: _this3.rootUrl + '/conwx/addpic',
          filePath: _this3.imgfiles[i],
          formData: { CWXID: CWXID },
          name: 'file',
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success: function success(res) {
            console.log(res);
            if (res.data === '1') {
              wx.showLoading({ title: '\u56FE\u7247' + (i + 1) + '\u4E0A\u4F20\u6210\u529F' });
            } else {
              wx.showLoading({ title: '\u56FE\u7247' + (i + 1) + '\u4E0A\u4F20\u5931\u8D25' });
            }
            if (--counter == 0) {
              wx.showToast({ title: '问题上传成功' });
              var url = '../similar/main?title=' + _this3.title + '&text=' + _this3.text + '&tags=' + _this3.selectedTags.join(',') + '&imgs=' + _this3.imgfiles.join(',');
              wx.navigateTo({ url: url });
              _this3.canIclear = true;
            }
          },
          fail: function fail(res) {
            console.log(res);
          }
        });
      };

      for (var i = 0; i < time; i++) {
        _loop(i);
      }
    },
    clearData: function clearData() {
      this.title = this.text = '';
      this.selectedTags = [];
      this.styleTags = [];
      this.imgfiles = [];
      this.imgs = new Array(12).fill('');
      this.canIclear = false;
    },
    chooseImage: function chooseImage(e) {
      var _this4 = this;

      var count = 9 - this.imgfiles.length;
      if (count == 0) {
        if (!wx.showModal({
          title: '上传限制',
          content: '图片数量上限为9张\n请删除部分图片后再上传新图片',
          showCancel: false,
          success: function success(res) {
            if (res.confirm) {
              return false;
            }
          }
        })) {
          return;
        }
      }
      wx.chooseImage({
        count: count,
        sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
        sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
        success: function success(res) {
          // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
          console.log('图片路径');
          console.log(res.tempFilePaths);
          _this4.imgfiles = _this4.imgfiles.concat(res.tempFilePaths);
        }
      });
    }
  },
  onLoad: function onLoad() {
    this.type = this.$root.$mp.query.type;
  },
  onShow: function onShow() {
    if (this.canIclear) {
      this.clearData();
    }
  }
};

/***/ }),

/***/ 312:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  return _c('div', {
    staticClass: "consult"
  }, [_c('div', {
    staticClass: "search-bar"
  }, [_c('div', [_vm._v("标题:")]), _vm._v(" "), _c('input', {
    directives: [{
      name: "model",
      rawName: "v-model",
      value: (_vm.title),
      expression: "title"
    }],
    attrs: {
      "placeholder": "请输入15字以内的标题",
      "maxlength": "15",
      "eventid": '0'
    },
    domProps: {
      "value": (_vm.title)
    },
    on: {
      "input": function($event) {
        if ($event.target.composing) { return; }
        _vm.title = $event.target.value
      }
    }
  })]), _vm._v(" "), _c('div', {
    staticClass: "subtitle"
  }, [_vm._v("类别(最多选3个)")]), _vm._v(" "), _c('div', {
    staticClass: "select-grid"
  }, _vm._l((_vm.sort), function(item, i) {
    return _c('div', {
      key: i,
      staticClass: "grid-item",
      style: (_vm.styleTags[i]),
      attrs: {
        "eventid": '1-' + i
      },
      on: {
        "tap": function($event) {
          _vm.selectTags(i)
        }
      }
    }, [_c('img', {
      class: _vm.classes[i],
      attrs: {
        "src": '/static/imgs/1/' + i + _vm.imgs[i] + '.png'
      }
    }), _vm._v(" "), _c('div', [_vm._v(_vm._s(item))])])
  })), _vm._v(" "), _c('div', {
    staticClass: "subtitle"
  }, [_vm._v("正文")]), _vm._v(" "), _c('div', {
    staticClass: "textarea"
  }, [_c('textarea', {
    directives: [{
      name: "model",
      rawName: "v-model",
      value: (_vm.text),
      expression: "text"
    }],
    attrs: {
      "placeholder": '请输入' + _vm.type + '的正文',
      "maxlength": "200",
      "eventid": '2'
    },
    domProps: {
      "value": (_vm.text)
    },
    on: {
      "input": function($event) {
        if ($event.target.composing) { return; }
        _vm.text = $event.target.value
      }
    }
  })]), _vm._v(" "), _c('div', {
    staticClass: "subtitle"
  }, [_vm._v("添加图片")]), _vm._v(" "), _c('div', {
    staticClass: "img-box",
    staticStyle: {
      "background": "white"
    }
  }, [_vm._l((_vm.imgfiles), function(item, i) {
    return _c('div', {
      key: i,
      attrs: {
        "eventid": '4-' + i
      },
      on: {
        "tap": function($event) {
          _vm.previewImg(i)
        }
      }
    }, [_c('img', {
      attrs: {
        "src": item
      }
    }), _c('div', {
      attrs: {
        "eventid": '3-' + i
      },
      on: {
        "tap": function($event) {
          $event.stopPropagation();
          _vm.cancelImg(i)
        }
      }
    }, [_c('img', {
      attrs: {
        "src": "/static/imgs/cancel.png"
      }
    })])])
  }), _vm._v(" "), _c('img', {
    attrs: {
      "src": "/static/imgs/upload.png",
      "eventid": '5'
    },
    on: {
      "tap": _vm.chooseImage
    }
  })], 2), _vm._v(" "), _c('div', {
    staticClass: "commit"
  }, [_c('div', {
    attrs: {
      "eventid": '6'
    },
    on: {
      "tap": _vm.commit
    }
  }, [_vm._v("提交")])])])
}
var staticRenderFns = []
render._withStripped = true
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);
if (false) {
  module.hot.accept()
  if (module.hot.data) {
     require("vue-hot-reload-api").rerender("data-v-244d919a", esExports)
  }
}

/***/ })

},[308]);
//# sourceMappingURL=main.js.map