search.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view>
  3. <d-search-log :placeholder="'搜索美食'" :color_border="color_border" :color_text="color_border"
  4. :search_list_old_man_num='15' :search_list_hot="search_list_hot" :store_key="store_key" :input_text="input_text"
  5. @onClickDelAllApi="onClickDelAll" @onSearchNameApi="onSearchName"></d-search-log>
  6. <!-- <u-popup :show="isRecorderManager" mode="bottom">
  7. <view class="shqx" v-if="longPress == '2'">
  8. 上划取消
  9. </view>
  10. <view class="record-layer">
  11. <view class="record-box">
  12. <view class="record-btn-layer" v-if="tempFilePath == ''">
  13. <view class="record-btn">
  14. <image src="../../static/mic.png" mode="widthFix" style="width:120rpx;height: auto;"
  15. @longpress="longpressBtn" @touchend="touchendBtn" @touchmove="handleTouchMove"></image>
  16. <text class="text">{{longPress == '1' ? '按住说出姓名' : '松开自动识别'}}</text>
  17. </view>
  18. </view>
  19. <view class="prompt-layer prompt-layer-1" v-if="longPress == '2'">
  20. <view class="prompt-loader">
  21. <view class="em" v-for="(item,index) in 15" :key="index"></view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </u-popup> -->
  27. <u-toast ref="uToast"></u-toast>
  28. </view>
  29. </template>
  30. <script>
  31. import dSearchLog from '@/uni_modules/d-search-log/components/d-search-log/d-search-log.vue'
  32. const recorderManager = uni.getRecorderManager();
  33. const innerAudioContext = uni.createInnerAudioContext();
  34. var init // 录制时长计时器
  35. var timer // 播放 录制倒计时
  36. export default {
  37. components: {
  38. "dSearchLog": dSearchLog
  39. },
  40. data() {
  41. return {
  42. duration: 2000, //录音最大值ms 60000/1分钟
  43. tempFilePath: '', //音频路径
  44. playStatus: 0, //录音播放状态 0:未播放 1:正在播放
  45. longPress: '1',
  46. tempFilePath: '',
  47. color_border: "#00aaff",
  48. search_list_hot: [],
  49. store_key: 'search_list',
  50. isRecorderManager: false,
  51. is_clock: true,
  52. startPoint: "",
  53. input_text:""
  54. };
  55. },
  56. onLoad(options) {
  57. if (options.mic == 1) {
  58. this.isRecorderManager = true
  59. }
  60. },
  61. methods: {
  62. onClickDelAll() {},
  63. onSearchName(e) {
  64. if(e.length>10){
  65. var text = e.substring(0, 10)
  66. }else{
  67. var text = e
  68. }
  69. uni.setStorageSync('search_food_val', text);
  70. uni.switchTab({
  71. url: "/pages/food/food"
  72. })
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .shqx {
  79. position: absolute;
  80. top: -100rpx;
  81. left: 0;
  82. right: 0;
  83. margin: auto;
  84. text-align: center;
  85. color: rgba(221, 221, 221, 1);
  86. }
  87. .record-box {
  88. width: 100%;
  89. position: relative;
  90. top: 80rpx;
  91. }
  92. .record-btn-layer {
  93. width: 100%;
  94. display: flex;
  95. justify-content: center;
  96. }
  97. .record-btn-layer button::after {
  98. border: none;
  99. }
  100. .record-btn-layer button {
  101. font-size: 14px;
  102. line-height: 38px;
  103. width: 100%;
  104. height: 38px;
  105. border-radius: 8px;
  106. text-align: center;
  107. background: rgba(56, 86, 156, 1);
  108. }
  109. .record-btn-layer button image {
  110. width: 16px;
  111. height: 16px;
  112. margin-right: 4px;
  113. vertical-align: middle;
  114. }
  115. .record-btn-layer .record-btn-2 {
  116. background: rgba(56, 86, 156, 1);
  117. }
  118. .prompt-layer {
  119. border-radius: 8px;
  120. background: rgba(56, 86, 156, 1);
  121. padding: 8px 16px;
  122. box-sizing: border-box;
  123. position: absolute;
  124. left: 50%;
  125. transform: translateX(-50%);
  126. }
  127. .prompt-layer::after {
  128. content: '';
  129. display: block;
  130. border: 6px solid rgba(0, 0, 0, 0);
  131. border-top-color: rgba(56, 86, 156, 1);
  132. position: absolute;
  133. bottom: -10px;
  134. left: 50%;
  135. transform: translateX(-50%);
  136. }
  137. .prompt-layer-1 {
  138. font-size: 12px;
  139. width: 128px;
  140. text-align: center;
  141. display: flex;
  142. flex-direction: column;
  143. align-items: center;
  144. justify-content: center;
  145. top: -240px;
  146. }
  147. .del {
  148. position: absolute;
  149. top: -200rpx;
  150. .img {
  151. width: 100rpx;
  152. }
  153. }
  154. .prompt-layer-1 .p {
  155. color: #000000;
  156. }
  157. .prompt-layer-1 .span {
  158. color: #fff;
  159. }
  160. .prompt-loader .em {}
  161. .prompt-loader {
  162. width: 96px;
  163. height: 20px;
  164. display: flex;
  165. align-items: center;
  166. justify-content: space-between;
  167. margin-bottom: 6px;
  168. }
  169. .prompt-loader .em {
  170. display: block;
  171. background: #fff;
  172. width: 1px;
  173. height: 10%;
  174. margin-right: 2.5px;
  175. float: left;
  176. }
  177. .prompt-loader .em:last-child {
  178. margin-right: 0px;
  179. }
  180. .prompt-loader .em:nth-child(1) {
  181. animation: load 2.5s 1.4s infinite linear;
  182. }
  183. .prompt-loader .em:nth-child(2) {
  184. animation: load 2.5s 1.2s infinite linear;
  185. }
  186. .prompt-loader .em:nth-child(3) {
  187. animation: load 2.5s 1s infinite linear;
  188. }
  189. .prompt-loader .em:nth-child(4) {
  190. animation: load 2.5s 0.8s infinite linear;
  191. }
  192. .prompt-loader .em:nth-child(5) {
  193. animation: load 2.5s 0.6s infinite linear;
  194. }
  195. .prompt-loader .em:nth-child(6) {
  196. animation: load 2.5s 0.4s infinite linear;
  197. }
  198. .prompt-loader .em:nth-child(7) {
  199. animation: load 2.5s 0.2s infinite linear;
  200. }
  201. .prompt-loader .em:nth-child(8) {
  202. animation: load 2.5s 0s infinite linear;
  203. }
  204. .prompt-loader .em:nth-child(9) {
  205. animation: load 2.5s 0.2s infinite linear;
  206. }
  207. .prompt-loader .em:nth-child(10) {
  208. animation: load 2.5s 0.4s infinite linear;
  209. }
  210. .prompt-loader .em:nth-child(11) {
  211. animation: load 2.5s 0.6s infinite linear;
  212. }
  213. .prompt-loader .em:nth-child(12) {
  214. animation: load 2.5s 0.8s infinite linear;
  215. }
  216. .prompt-loader .em:nth-child(13) {
  217. animation: load 2.5s 1s infinite linear;
  218. }
  219. .prompt-loader .em:nth-child(14) {
  220. animation: load 2.5s 1.2s infinite linear;
  221. }
  222. .prompt-loader .em:nth-child(15) {
  223. animation: load 2.5s 1.4s infinite linear;
  224. }
  225. @keyframes load {
  226. 0% {
  227. height: 10%;
  228. }
  229. 50% {
  230. height: 100%;
  231. }
  232. 100% {
  233. height: 10%;
  234. }
  235. }
  236. .prompt-layer-2 {
  237. // top: -540px;
  238. }
  239. .prompt-layer-2 .text {
  240. color: rgba(0, 0, 0, 1);
  241. font-size: 12px;
  242. }
  243. .record-btn {
  244. display: flex;
  245. flex-direction: column;
  246. justify-content: center;
  247. align-items: center;
  248. .text {
  249. margin-top: 20rpx;
  250. }
  251. }
  252. /deep/.u-popup__content {
  253. padding-bottom: 100rpx;
  254. // background: linear-gradient(180deg, rgba(204, 204, 204, 0.95) 0%, rgba(203, 203, 203, 0.01) 100%) !important;
  255. border-radius: 50% 50% 0 0;
  256. }
  257. .record-layerP {
  258. position: relative;
  259. top: 50px;
  260. }
  261. </style>