pageOne.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="page-itemOne">
  3. <u-row justify="space-between" customStyle="margin-bottom: 10px">
  4. <u-col span="3">
  5. <div class="page-itemOne-title">图片资料</div>
  6. </u-col>
  7. <u-col span="3.5">
  8. <u-button size="small"
  9. style="border-radius: 20rpx;border-color: #007AFF;color: #007AFF;">复制全部图片</u-button>
  10. </u-col>
  11. </u-row>
  12. <!-- 实物图卡片 -->
  13. <view class="card_wrap">
  14. <view class="card-title">实物图</view>
  15. <view class="image-upload-container">
  16. <view class="image-list">
  17. <view class="image-item" v-for="(item, index) in form.truePic" :key="'truePic-' + index">
  18. <pic-comp :src="item"></pic-comp>
  19. <view class="delete-btn" @click="deleteImage('truePic', index)">×</view>
  20. </view>
  21. <view class="upload-btn" @click="uploadImage('truePic')">
  22. <u-icon name="plus" size="40" color="#999"></u-icon>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 聊天记录卡片 -->
  28. <view class="card_wrap">
  29. <view class="card-title">聊天记录</view>
  30. <view class="image-upload-container">
  31. <view class="image-list">
  32. <view class="image-item" v-for="(item, index) in form.chatRecords" :key="'chatRecords-' + index">
  33. <pic-comp :src="item"></pic-comp>
  34. <view class="delete-btn" @click="deleteImage('chatRecords', index)">×</view>
  35. </view>
  36. <view class="upload-btn" @click="uploadImage('chatRecords')">
  37. <u-icon name="plus" size="40" color="#999"></u-icon>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 基本信息卡片 -->
  43. <view class="info-card">
  44. <view class="info-card-title">基本信息</view>
  45. <u-row class="info-row">
  46. <u-col span="6">
  47. <view class="info-label">发单人</view>
  48. <view class="info-value">张三</view>
  49. </u-col>
  50. <u-col span="6">
  51. <view class="info-label">型号</view>
  52. <view class="info-value">iPhone 15 Pro</view>
  53. </u-col>
  54. </u-row>
  55. <u-row class="info-row">
  56. <u-col span="6">
  57. <view class="info-label">上门时间</view>
  58. <view class="info-value">2025-12-20 14:30</view>
  59. </u-col>
  60. <u-col span="6">
  61. <view class="info-label">地址</view>
  62. <view class="info-value">北京市朝阳区建国路88号</view>
  63. </u-col>
  64. </u-row>
  65. </view>
  66. <!-- 联系方式卡片 -->
  67. <view class="connect">
  68. <view class="connect-card phone-card" @click="handlePhoneClick">
  69. <u-icon name="phone" size="40" color="#07C160" style="margin-bottom: 10rpx;"></u-icon>
  70. <view class="connect-title">电话</view>
  71. <!-- 小红点 -->
  72. <view v-if="phone" class="red-dot"></view>
  73. </view>
  74. <view class="connect-card wechat-card" @click="handleWechatClick">
  75. <u-icon name="chat" size="40" color="#07C160" style="margin-bottom: 10rpx;"></u-icon>
  76. <view class="connect-title">微信</view>
  77. <!-- 小红点 -->
  78. <view v-if="wechat" class="red-dot"></view>
  79. </view>
  80. </view>
  81. <u-button @click="handleNextClick" type="primary" size="middle" style="border-radius: 20rpx;">下一步</u-button>
  82. </view>
  83. </template>
  84. <script>
  85. import picComp from './picComp.vue'
  86. export default {
  87. components: {
  88. picComp
  89. },
  90. data() {
  91. return {
  92. form: {
  93. truePic: [],
  94. chatRecords: [],
  95. },
  96. phone: '13800138000',
  97. wechat: 'wechat123456',
  98. // 控制小红点显示的变量
  99. }
  100. },
  101. methods: {
  102. // 上传图片
  103. uploadImage(type) {
  104. uni.chooseImage({
  105. count: 9 - this.form[type].length, // 最多选择9张
  106. sizeType: ['compressed'], // 压缩图片
  107. sourceType: ['album', 'camera'], // 从相册选择或拍照
  108. success: (res) => {
  109. const tempFilePaths = res.tempFilePaths
  110. // 将图片路径添加到对应的数组中
  111. this.form[type] = [...this.form[type], ...tempFilePaths]
  112. // 这里可以添加上传到服务器的逻辑
  113. // this.uploadToServer(tempFilePaths, type)
  114. },
  115. fail: (err) => {
  116. console.error('选择图片失败:', err)
  117. }
  118. })
  119. },
  120. // 删除图片
  121. deleteImage(type, index) {
  122. uni.showModal({
  123. title: '提示',
  124. content: '确定要删除这张图片吗?',
  125. success: (res) => {
  126. if (res.confirm) {
  127. this.form[type].splice(index, 1)
  128. }
  129. }
  130. })
  131. },
  132. // 上传到服务器(示例)
  133. uploadToServer(filePaths, type) {
  134. filePaths.forEach((filePath, index) => {
  135. uni.uploadFile({
  136. url: 'your-upload-api-url', // 替换为实际的上传接口
  137. filePath: filePath,
  138. name: 'file',
  139. formData: {
  140. type: type
  141. },
  142. success: (uploadRes) => {
  143. const data = JSON.parse(uploadRes.data)
  144. // 上传成功后,将临时路径替换为服务器返回的路径
  145. const tempIndex = this.form[type].indexOf(filePath)
  146. if (tempIndex !== -1) {
  147. this.form[type][tempIndex] = data.url // 假设服务器返回data.url
  148. }
  149. },
  150. fail: (err) => {
  151. console.error('上传图片失败:', err)
  152. }
  153. })
  154. })
  155. },
  156. // 电话卡片点击事件
  157. handlePhoneClick() {
  158. console.log('电话卡片被点击', '电话号码:', this.phone)
  159. // 这里可以添加拨打电话的逻辑,例如调用uni.makePhoneCall
  160. },
  161. // 微信卡片点击事件
  162. handleWechatClick() {
  163. console.log('微信卡片被点击', '微信号:', this.wechat)
  164. // 这里可以添加打开微信的逻辑
  165. },
  166. // 下一步
  167. handleNextClick() {
  168. // 校验表单
  169. if (!this.form.truePic.length) {
  170. uni.showToast({
  171. title: '请上传实物图',
  172. icon: 'none'
  173. })
  174. return
  175. }
  176. if (!this.form.chatRecords.length) {
  177. uni.showToast({
  178. title: '请上传聊天记录',
  179. icon: 'none'
  180. })
  181. return
  182. }
  183. this.$emit('handleNextClick', {
  184. nowPage: 'formOne',
  185. form: this.form,
  186. })
  187. }
  188. }
  189. }
  190. </script>
  191. <style scoped lang="scss">
  192. // 导入公共样式
  193. @import './common.scss';
  194. // 主样式
  195. .page-itemOne {
  196. @extend .page-container;
  197. }
  198. .page-itemOne-title {
  199. @include font-styles($size: title, $weight: bold, $color: primary);
  200. }
  201. .page-itemOne-form {
  202. @include font-styles($size: tiny, $weight: semi-bold, $color: secondary);
  203. text-wrap: nowrap;
  204. }
  205. .image-upload-container {
  206. padding: map-get($sizes, padding-sm) map-get($sizes, padding);
  207. }
  208. .image-list {
  209. display: flex;
  210. flex-wrap: wrap;
  211. gap: 20rpx;
  212. }
  213. .image-item {
  214. position: relative;
  215. width: 200rpx;
  216. height: 200rpx;
  217. box-sizing: border-box;
  218. }
  219. .delete-btn {
  220. position: absolute;
  221. top: -10rpx;
  222. right: -10rpx;
  223. width: 40rpx;
  224. height: 40rpx;
  225. background-color: #ff4d4f;
  226. color: #fff;
  227. border-radius: 50%;
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. @include font-styles($size: tiny, $weight: bold);
  232. z-index: 10;
  233. }
  234. .upload-btn {
  235. width: 200rpx;
  236. height: 200rpx;
  237. border: 8rpx dashed #ddd;
  238. border-radius: 30rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. background-color: #f9f9f9;
  243. box-sizing: border-box;
  244. }
  245. /* 基本信息卡片样式 */
  246. .info-card {
  247. @include card;
  248. margin-top: 20rpx;
  249. margin-bottom: 20rpx;
  250. padding: map-get($sizes, padding-sm) map-get($sizes, padding);
  251. &:hover {
  252. @include shadow(2);
  253. }
  254. }
  255. .info-card-title {
  256. @include font-styles($size: title, $weight: bold, $color: primary);
  257. margin-bottom: 25rpx;
  258. padding-bottom: 15rpx;
  259. border-bottom: 1rpx solid map-get($colors, border);
  260. }
  261. .info-row {
  262. margin-bottom: 20rpx;
  263. }
  264. .info-label {
  265. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  266. margin-bottom: 8rpx;
  267. }
  268. .info-value {
  269. @include font-styles($size: small, $weight: regular, $color: secondary, $line-height: small);
  270. word-break: break-all;
  271. }
  272. /* 联系方式卡片样式 */
  273. .connect {
  274. display: flex;
  275. justify-content: space-between;
  276. margin: 20rpx 0;
  277. gap: 20rpx;
  278. }
  279. .connect-card {
  280. flex: 1;
  281. @include card;
  282. padding: 30rpx;
  283. display: flex;
  284. flex-direction: column;
  285. align-items: center;
  286. box-sizing: border-box;
  287. position: relative;
  288. &:hover {
  289. @include shadow(2);
  290. }
  291. }
  292. .connect-title {
  293. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  294. margin-bottom: 8rpx;
  295. }
  296. .connect-value {
  297. @include font-styles($size: small, $weight: medium, $color: secondary);
  298. }
  299. /* 小红点样式 */
  300. .red-dot {
  301. position: absolute;
  302. top: 15rpx;
  303. right: 15rpx;
  304. width: 16rpx;
  305. height: 16rpx;
  306. background-color: #ff4d4f;
  307. border-radius: 50%;
  308. box-shadow: 0 0 4rpx rgba(255, 77, 79, 0.3);
  309. }
  310. </style>