check.vue 5.8 KB

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