selectInterview.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="container">
  3. <nav-bar :title="title" color="#000"></nav-bar>
  4. <view class="content">
  5. <view class="cell-box">
  6. <view class="cell-title">{{type == 'address'?'面试地点':'姓名'}}</view>
  7. <u-input disabled v-model="address" v-if="type=='address'" type="text" @click="selectAddress" :border="true"
  8. placeholder="请选择地址"/>
  9. <u-input v-else v-model="address" type="text" :border="true"
  10. :placeholder="type == 'address'?'请输入办公大楼名称,例:碧桂园凤凰智谷':'请输入联系人姓名'" />
  11. </view>
  12. <view class="cell-box">
  13. <view class="cell-title">{{type == 'address'?'楼层/单元室':'电话'}}</view>
  14. <div class="input-wrapper">
  15. <u-input v-model="floor" :type="type == 'address'?'text':'number'" :border="true"
  16. :placeholder="type == 'address'?'楼层/单元室/门牌号,例:3层302室':'请输入联系人电话'" @input="handleInput"
  17. :maxlength="20" />
  18. <view class="word-count" v-if="type == 'address'">{{ floorLength }}/20</view>
  19. </div>
  20. </view>
  21. </view>
  22. <button class="btn" :disabled="!canSave" @click="goBack">保存</button>
  23. </view>
  24. </template>
  25. <script>
  26. import navBar from "@/components/nav-bar/index.vue";
  27. export default {
  28. components: {
  29. navBar
  30. },
  31. data() {
  32. return {
  33. title: '面试地址',
  34. id: '',
  35. address: '',
  36. latitude:0,
  37. longitude:0,
  38. floor: '',
  39. floorLength: 0,
  40. callback: null,
  41. type: ''
  42. };
  43. },
  44. onLoad(options) {
  45. this.type = options.type
  46. if (this.type === 'address') {
  47. this.title = '面试地址'
  48. } else if (this.type === 'addPerson') {
  49. this.title = '添加联系人'
  50. } else if (this.type === 'editPerson') {
  51. this.title = '编辑联系人'
  52. }
  53. const eventChannel = this.getOpenerEventChannel();
  54. this.callback = null;
  55. eventChannel.on('sendData', (data) => {
  56. this.callback = data.callback;
  57. if (data.type === 'editPerson' && data.item) {
  58. this.id = data.item.id
  59. this.address = data.item.hrName
  60. this.floor = data.item.hrPhone
  61. }
  62. if (data.type === 'address' && data.item) {
  63. this.latitude = data.item.latitude
  64. this.longitude = data.item.longitude
  65. this.address = data.item.address
  66. this.floor = data.item.detailedAddress
  67. }
  68. })
  69. },
  70. computed: {
  71. canSave() {
  72. const address = (this.address || '').trim()
  73. const floor = (this.floor || '').trim()
  74. if (!address) {
  75. return false
  76. }
  77. if (!floor) {
  78. return false
  79. }
  80. return true
  81. }
  82. },
  83. methods: {
  84. handleInput(val) {
  85. this.floorLength = val.length;
  86. },
  87. goBack() {
  88. if (this.callback) {
  89. if (this.type === 'address') {
  90. this.callback({
  91. address: this.address,
  92. floor: this.floor,
  93. latitude:this.latitude,
  94. longitude:this.longitude
  95. })
  96. } else if (this.type === 'addPerson') {
  97. this.$Request.postJson('/app/interviewRecord/addHrPhone', {
  98. hrName: this.address, //会话对象的id
  99. hrPhone: this.floor, //当前登录者Id
  100. // type:2,
  101. }).then(ret => {
  102. if (ret.code == 0) {
  103. this.callback({
  104. id: Date.now(),
  105. hrName: this.address,
  106. hrPhone: this.floor
  107. })
  108. }
  109. })
  110. } else if (this.type === 'editPerson') {
  111. this.$Request.postJson('/app/interviewRecord/addHrPhone', {
  112. hrName: this.address,
  113. hrPhone: this.floor,
  114. // type:2,
  115. }).then(ret => {
  116. if (ret.code == 0) {
  117. this.callback({
  118. id: this.id,
  119. name: this.address,
  120. phone: this.floor
  121. })
  122. }
  123. })
  124. }
  125. }
  126. uni.navigateBack();
  127. },
  128. selectAddress: function() {
  129. var that = this;
  130. var latitude;
  131. var longitude;
  132. if (this.latitude != "") {
  133. latitude = this.latitude;
  134. longitude = this.longitude;
  135. that.chooseLocation(latitude, longitude);
  136. } else {
  137. if(this.$queue.getData('latitude')){
  138. latitude = this.$queue.getData('latitude');
  139. longitude = this.$queue.getData('longitude');
  140. }
  141. that.chooseLocation(latitude, longitude);
  142. }
  143. },
  144. chooseLocation(latitude, longitude) {
  145. var that = this;
  146. if (parseInt(latitude) <= 0) {
  147. latitude = "";
  148. longitude = "";
  149. }
  150. uni.chooseLocation({
  151. latitude: latitude,
  152. longitude: longitude,
  153. success: function(res) {
  154. console.log(res);
  155. if (res.latitude == undefined)
  156. return that.$common.toast("请选择一个地址");
  157. that.address = res.address + res.name;
  158. that.latitude = res.latitude;
  159. that.longitude = res.longitude;
  160. },
  161. fail: function(err) {
  162. console.log("选择位置失败:", err);
  163. },
  164. });
  165. },
  166. }
  167. };
  168. </script>
  169. <style scoped lang="scss">
  170. .container {
  171. display: flex;
  172. flex-direction: column;
  173. height: 100vh;
  174. .content {
  175. flex: 1;
  176. display: flex;
  177. flex-direction: column;
  178. z-index: 0;
  179. padding: 40rpx;
  180. .cell-box {
  181. margin-bottom: 32rpx;
  182. .cell-title {
  183. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  184. font-family: DM Sans;
  185. font-size: 28rpx;
  186. font-weight: 500;
  187. line-height: 44rpx;
  188. letter-spacing: 0.5%;
  189. margin-bottom: 16rpx;
  190. }
  191. .input-wrapper {
  192. position: relative;
  193. .word-count {
  194. position: absolute;
  195. top: 50%;
  196. right: 26rpx;
  197. transform: translateY(-50%);
  198. color: rgba(153, 153, 153, 1);
  199. font-family: DM Sans;
  200. font-size: 24rpx;
  201. font-weight: 500;
  202. line-height: 48rpx;
  203. letter-spacing: 0.5%;
  204. }
  205. }
  206. ::v-deep .uni-input-placeholder {
  207. color: rgba(153, 153, 153, 1);
  208. font-family: DM Sans;
  209. font-size: 24rpx;
  210. font-weight: 500;
  211. line-height: 48rpx;
  212. letter-spacing: 0.5%;
  213. }
  214. ::v-deep .u-input {
  215. height: 70rpx;
  216. box-sizing: border-box;
  217. border: 1px solid rgba(227, 231, 236, 1);
  218. border-radius: 48rpx;
  219. background: rgba(255, 255, 255, 1);
  220. padding: 0 32rpx !important;
  221. box-sizing: border-box;
  222. text-align: left !important;
  223. }
  224. ::v-deep .uni-input-input {
  225. font-family: DM Sans;
  226. font-size: 24rpx !important;
  227. font-weight: 500;
  228. line-height: 48rpx;
  229. letter-spacing: 0.5%;
  230. color: #000 !important;
  231. }
  232. }
  233. }
  234. .btn {
  235. display: flex;
  236. height: 80rpx;
  237. // padding: 16rpx 32rpx;
  238. border-radius: 999px;
  239. background: rgba(255, 102, 0, 1);
  240. margin: 60rpx;
  241. color: rgba(255, 255, 255, 1);
  242. font-family: DM Sans;
  243. font-size: 32rpx;
  244. font-weight: 400;
  245. line-height: 80rpx;
  246. letter-spacing: 0%;
  247. box-sizing: border-box;
  248. justify-content: center;
  249. &:active {
  250. background: rgba(255, 102, 0, 0.8);
  251. }
  252. ::v-deep uni-button:after {
  253. border: none !important;
  254. }
  255. }
  256. uni-button[disabled] {
  257. background: rgba(255, 102, 0, 0.5) !important;
  258. }
  259. }
  260. </style>