myrecordedit.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="page">
  3. <view class="form">
  4. <u-form :model="form" ref="uForm">
  5. <u-form-item label-width="150" label="备注信息" prop="record_remark" required label-position="top">
  6. <u-input :placeholder="remarkTips" v-model="form.record_remark" type="textarea"></u-input>
  7. </u-form-item>
  8. </u-form>
  9. <view class="scoped-more-img" @click="addImg">
  10. <view class="t">上传图片</view>
  11. <image class="img" v-if="curImgUrl" :src="curImgUrl" mode="aspectFill"></image>
  12. </view>
  13. <u-gap height="60"></u-gap>
  14. <u-button type="primary" @click="submitHandle">提交</u-button>
  15. </view>
  16. <!-- 列表选择 -->
  17. <u-select mode="single-column" :list="propertySelectList" v-model="propertySelectShow"
  18. @confirm="propertySelectConfirm"></u-select>
  19. <!-- modal -->
  20. <!-- utoast -->
  21. <u-toast ref="uToast" />
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. curImgUrl: '',
  29. form: {
  30. record_remark: null,
  31. },
  32. customer_id: null,
  33. rules: {
  34. record_remark: [{
  35. required: true,
  36. message: '备注不能为空',
  37. trigger: ['change']
  38. }, ]
  39. },
  40. remarkTips: '请输入:购房预算(总价/均价/面积段)~现居住区域~现居住产品/面积段~工作类型~购房需求/关注点~已经看过的房源情况',
  41. propertySelectShow: false,
  42. propertySelectList: [],
  43. };
  44. },
  45. onLoad(data) {
  46. this.customer_id = data.id
  47. },
  48. created() {},
  49. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  50. onReady() {
  51. this.$refs.uForm.setRules(this.rules);
  52. },
  53. methods: {
  54. // // 选择所属项目回调
  55. // propertySelectConfirm(e) {
  56. // e.map((val, index) => {
  57. // this.form.estate_id = val.value;
  58. // this.form.estate_name = val.label;
  59. // });
  60. // },
  61. addImg () {
  62. let token = uni.getStorageSync('MD_token')
  63. const that = this
  64. uni.chooseImage({
  65. count: 1, // 默认9
  66. sizeType: ['compressed'],
  67. sourceType: ['album', 'camera'],
  68. success: function (res) {
  69. const tempFilePaths = res.tempFilePaths
  70. uni.uploadFile({
  71. url: uni.baseUrl + 'api/upload/cloud',
  72. filePath: tempFilePaths[0],
  73. name: 'upload',
  74. formData: {
  75. 'token': token
  76. },
  77. success (res){
  78. const cData = JSON.parse(res.data)
  79. that.curImgUrl = cData.data.url
  80. }
  81. })
  82. }
  83. })
  84. },
  85. submitHandle() {
  86. const that = this
  87. this.$refs.uForm.validate(valid => {
  88. if (valid) {
  89. // 验证成功
  90. let apiStr = 'apiprivaterecordadd'
  91. let params = {
  92. record_remark: that.form.record_remark,
  93. customer_id: that.customer_id
  94. }
  95. if (that.curImgUrl) params.record_img = that.curImgUrl
  96. if (that.isEdit) {
  97. apiStr = 'apiprivaterecordedit'
  98. params.id = that.form.id
  99. }
  100. uni.api.cust[apiStr](params).then(res => {
  101. if (that.isEdit) {
  102. uni.$msgConfirm('编辑成功', () => {
  103. uni.reLaunch({
  104. url: '/pages/cust/my'
  105. })
  106. }, () => {
  107. uni.reLaunch({
  108. url: '/pages/cust/my'
  109. })
  110. })
  111. } else {
  112. uni.$msgConfirm('添加跟进记录成功,是否前往列表?', () => {
  113. uni.navigateBack()
  114. }, () => {
  115. this.form = {
  116. record_remark: null,
  117. }
  118. })
  119. }
  120. })
  121. } else {
  122. console.log('验证失败');
  123. }
  124. });
  125. },
  126. }
  127. };
  128. </script>
  129. <style lang="scss">
  130. .page {
  131. padding: 20rpx;
  132. background-color: #ffffff;
  133. }
  134. .form {
  135. border-radius: 10rpx;
  136. padding: 0 40rpx;
  137. }
  138. .popup-body {
  139. .tips-title {
  140. font-size: $u-p;
  141. margin-bottom: 20rpx;
  142. }
  143. .tips-content {
  144. font-size: $u-p2;
  145. color: $u-tips-color;
  146. margin-bottom: 60rpx;
  147. }
  148. }
  149. .id_card {
  150. color: #606266;
  151. width: 100%;
  152. height: 350rpx;
  153. display: flex;
  154. flex-direction: column;
  155. align-items: center;
  156. justify-content: center;
  157. background-color: #f4f5f6;
  158. font-size: $u-p2;
  159. }
  160. .footer {
  161. position: absolute;
  162. text-align: center;
  163. bottom: 40rpx;
  164. font-size: $u-p2;
  165. .agreement {
  166. color: $u-type-error;
  167. }
  168. }
  169. .slot-content {
  170. font-size: 28rpx;
  171. color: $u-content-color;
  172. padding: 20rpx;
  173. }
  174. .scoped-more-img {
  175. padding-top: 30rpx;
  176. color: #2d8cf0;
  177. text-decoration: underline;
  178. .t {
  179. padding-bottom: 20rpx;
  180. }
  181. .img {
  182. width: 200rpx;
  183. height: 200rpx;
  184. }
  185. }
  186. </style>