check.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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="curName">
  6. <u-input placeholder="请输入推荐人" v-model="curName" disabled="true" type="text"></u-input>
  7. </u-form-item>
  8. <!-- <u-form-item label-width="150" label="中间四位" v-if="oldPhone.indexOf('****') > -1">
  9. <u-input placeholder="请输入中间四位" v-model="b4" type="number"></u-input>
  10. </u-form-item> -->
  11. <u-form-item label-width="150" label="报备状态" prop="report_state" required>
  12. <u-radio-group v-model="form.report_state" active-color="#2979ff">
  13. <u-radio name="1">有效</u-radio>
  14. <u-radio name="3">无效</u-radio>
  15. </u-radio-group>
  16. </u-form-item>
  17. <u-form-item label-position="top" label-width="150" label="报备二维码(非江投必填)" prop="report_code">
  18. <view class="id_card" @click="uploadImage">
  19. <u-icon v-if="form.report_code == null" name="plus" size="32" color="#606266"></u-icon>
  20. <text v-if="form.report_code == null">请先上传报备二维码照片</text>
  21. <image v-if="form.report_code != null" :src="form.report_code" mode="aspectFill"></image>
  22. </view>
  23. <view style="color: #999" @click="setDefaultImg">设置默认图</view>
  24. </u-form-item>
  25. <u-form-item label-width="150" label="备注信息" prop="remark" label-position="top">
  26. <u-radio-group v-model="form.remark" active-color="#2979ff">
  27. <u-radio name="已到访客户">已到访客户</u-radio>
  28. <u-radio name="项目集团老客户">项目集团老客户</u-radio>
  29. <u-radio name="他人报备有效期内">他人报备有效期内</u-radio>
  30. <u-radio name="其他原因">其他原因</u-radio>
  31. </u-radio-group>
  32. <u-input v-if="form.remark === '其他原因'" placeholder="备注信息,将显示在报备的详情页面" v-model="otherRemark" type="textarea"></u-input>
  33. </u-form-item>
  34. </u-form>
  35. <u-gap height="60"></u-gap>
  36. <u-button type="primary" @click="submitHandle">确定</u-button>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. var that;
  42. export default {
  43. data() {
  44. return {
  45. otherRemark: '',
  46. eId: '',
  47. curName: '',
  48. curId: '',
  49. oldPhone: '',
  50. b4: '',
  51. form: {
  52. report_code: null,
  53. report_state: '1',
  54. },
  55. };
  56. },
  57. onLoad(params) {
  58. this.curId = params.id
  59. this.eId = params.eid
  60. this.curName = `${params.name}--${params.phone}`
  61. this.oldPhone = `${params.phone}`
  62. },
  63. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  64. onReady() {
  65. this.$refs.uForm.setRules(this.rules);
  66. },
  67. methods: {
  68. setDefaultImg () {
  69. this.form.report_code = 'https://img.fangpiaovip.com/20230209031226-7200.png'
  70. },
  71. getTime(n) {
  72. let date = n ? new Date(n) : new Date()
  73. let year = date.getFullYear()
  74. let month = date.getMonth() + 1
  75. month = month > 9 ? month : '0' + month
  76. let day = date.getDate()
  77. day = day > 9 ? day : '0' + day
  78. let hour = date.getHours()
  79. hour = hour > 9 ? hour : '0' + hour
  80. let minute = date.getMinutes()
  81. minute = minute > 9 ? minute : '0' + minute
  82. let second = date.getSeconds()
  83. second = second > 9 ? second : '0' + second
  84. return `${year}-${month}-${day} ${hour}:${minute}:${second}`
  85. },
  86. uploadImgHandle (bc) {
  87. uni.chooseImage({
  88. count: 1,
  89. sizeType: ['compressed'],
  90. success: function(res) {
  91. const filePath = res.tempFilePaths[0];
  92. let token = uni.getStorageSync('MD_token') || ''
  93. uni.uploadFile({
  94. url: uni.baseUrl + 'api/upload/cloud',
  95. filePath,
  96. name: 'upload',
  97. formData: {
  98. 'token': token
  99. },
  100. success: (f) => {
  101. const cData = JSON.parse(f.data)
  102. if (cData.errno === 0) {
  103. if (bc && typeof(bc) === 'function') bc(cData.data)
  104. } else {
  105. uni.$msg(cData.errmsg || `未知错误-${cData.errno}`)
  106. }
  107. }
  108. })
  109. }
  110. })
  111. },
  112. // 上传照片
  113. uploadImage() {
  114. this.uploadImgHandle((d) => {
  115. this.form.report_code = d.url
  116. })
  117. },
  118. submitHandle() {
  119. const that = this
  120. uni.api.estate.apiestatedetail({
  121. id: that.eId
  122. }).then(function (dtl) {
  123. let remark = that.form.remark || ''
  124. if (remark === '其他原因') {
  125. remark = that.otherRemark
  126. }
  127. if (that.form.report_state == 1) {
  128. if (dtl.is_only == 2) {
  129. if (!that.form.report_code) {
  130. uni.$msg('非独家项目,请上传报备二维码~')
  131. return
  132. }
  133. }
  134. } else {
  135. if (!remark) {
  136. uni.$msg('报备无效请备注原因')
  137. return
  138. }
  139. }
  140. that.$refs.uForm.validate(valid => {
  141. if (valid) {
  142. let params = {
  143. ...that.form,
  144. id: that.curId,
  145. report_at: that.getTime(),
  146. remark,
  147. }
  148. // if (cPhone) params.phone = cPhone
  149. uni.api.cust.apireportverify(params).then(res => {
  150. uni.$msgConfirm('编辑成功', () => {
  151. uni.reLaunch({
  152. url: '/pages/agent/recommend/list'
  153. })
  154. }, () => {
  155. uni.reLaunch({
  156. url: '/pages/agent/recommend/list'
  157. })
  158. })
  159. })
  160. }
  161. });
  162. })
  163. // let cPhone = ''
  164. // if (that.oldPhone.indexOf('****') > -1) {
  165. // if (that.b4 && that.b4.length === 4) {
  166. // cPhone = that.oldPhone.replace('****', that.b4)
  167. // } else {
  168. // uni.$msg('请输入前三后四的中间四位')
  169. // return
  170. // }
  171. // }
  172. },
  173. // 以下是工具函数
  174. // 格式化日期的月份或天数的显示(小于10,在前面增加0)
  175. getFormatDate(value) {
  176. if (value == undefined || value == '') {
  177. return '';
  178. }
  179. var str = value;
  180. if (parseInt(value) < 10) {
  181. str = '0' + value;
  182. }
  183. return str;
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="scss">
  189. .page {
  190. background-color: #ffffff;
  191. }
  192. .form {
  193. border-radius: 10rpx;
  194. padding: 0 40rpx;
  195. }
  196. .popup-body {
  197. .tips-title {
  198. font-size: $u-p;
  199. margin-bottom: 20rpx;
  200. }
  201. .tips-content {
  202. font-size: $u-p2;
  203. color: $u-tips-color;
  204. margin-bottom: 60rpx;
  205. }
  206. }
  207. .id_card {
  208. color: #606266;
  209. width: 100%;
  210. height: 350rpx;
  211. display: flex;
  212. flex-direction: column;
  213. align-items: center;
  214. justify-content: center;
  215. background-color: #f4f5f6;
  216. font-size: $u-p2;
  217. border-radius: 10rpx;
  218. image {
  219. border-radius: 10rpx;
  220. }
  221. }
  222. .footer {
  223. position: relative;
  224. text-align: center;
  225. font-size: $u-p2;
  226. left: 0;
  227. bottom: 20rpx;
  228. .agreement {
  229. color: $u-theme-color;
  230. }
  231. }
  232. .slot-content {
  233. font-size: 28rpx;
  234. color: $u-content-color;
  235. padding: 20rpx;
  236. }
  237. .warp {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. justify-content: center;
  242. height: 100%;
  243. }
  244. .rect {
  245. width: 400rpx;
  246. height: 400rpx;
  247. background-color: #fff;
  248. }
  249. </style>