check.vue 5.6 KB

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